Esempio n. 1
0
void kiszed()
	{m_he=m_h.pop();
	//first v second?
	joe = m_he.first;
	joa=m_he.second/(2*NumPts);
	job=m_he.second%(2*NumPts);
	//mar nem kellenek, kitorolhetjuk
	//Ki kell szedni az osszes kapcsolodot:
	for(doublematrix::iterator i=crg.begin(); i!=crg.end();i++ )
		{if (i->first!=joa)
			{if (i->first!=job)
				{if (i->first<joa)
					{m_h.pop(hid[i->first][joa]);
					hid[i->first].erase(joa);
					}
				else
					{m_h.pop(hid[joa][i->first]);
					}
				if (i->first<job)
					{m_h.pop(hid[i->first][job]);
					hid[i->first].erase(job);
					}
				else
					{m_h.pop(hid[job][i->first]);
					}
				}					
			}
		}
	hid.erase(joa);
	hid.erase(job);
	}
Esempio n. 2
0
void median_maintainer::add(int elem)
{
    if (curr_size_ == 0) {
        top_ = elem;
        curr_size_ ++;
        return;
    }
    if (left_.size() >= right_.size()) {
        // insertion has to be in the right 
        if (elem > top_) {
            right_.add(elem);
        } else {
            right_.add(top_);
            left_.add(elem);
            top_ = left_.pop();
        }
        size_t diff_height = right_.size() - left_.size();
        assert(diff_height == 0 || diff_height == 1);
    } else {
        // insertion has to be in the left 
        if (elem < top_) {
            left_.add(elem);
        } else {
            left_.add(top_);
            right_.add(elem);
            top_ = right_.pop();
        }
        assert(left_.size() == right_.size());
    }
    curr_size_ ++;
}