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); }
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_ ++; }
void update2(int be) {//csak az uj el ertekeit kell updatelni //be adja meg, miaz uj index //bar ezt igazabol Nodes rogziti!, valoszinuleg Nodes-1 az erteke //de be kell hozni a heap-et az optimum kivalasztasahoz :( //joe=INF; double jobb; for(doublematrix::iterator i=crg.begin(); i!=crg.end();i++ ) {jobb=delta1(be,i->first); if (be<i->first) {hid[be][i->first]=m_h.push(jobb,be*2*NumPts+i->first); } else {if (be!=i->first) {hid[i->first][be]=m_h.push(jobb,i->first*2*NumPts+be); } } } kiszed(); };
void update_in() {//kezdeti szamolas: heap feltoltese //de be kell hozni a heap-et az optimum kivalasztasahoz :( //joe=INF; double jobb; for(doublematrix::iterator i=crg.begin(); i!=crg.end();i++ ) {//tmp_el.start=i; // cout << i->first << "\n"; doublematrix::iterator j=i; j++; //joe=INF; for(; j!=crg.end();j++ ) {//if ((i->first)<(j->first)) //jobb=delta(i->first,j->first)+hist[i->first]+hist[j->first]; //hid[i->first][j->first]=m_h.push(delta(i->first,j->first)+hist[i->first]+hist[j->first],i->first*2*NumPts+j->first); jobb=delta1(i->first,j->first); // cout << jobb << "\n"; hid[i->first][j->first]=m_h.push(jobb,i->first*2*NumPts+j->first); } } kiszed(); };