static void heal(pqueue q, index where) { index left= where<<1; index right = left+1; index min = where; index len = vector_length(q->v); if (left <= len) if (qcompare(q, left, min)) min = left; if (right <= len) if (qcompare(q, right, min)) min = right; if (min != where) { swap(q, min, where); heal(q, min); } }
void SynopsisMD2::mark_used(vector<int> low,vector<int> high) { vector<history> hist; struct nodeMD res = navigate(low,hist); while( !greater(res.low,high)) { /* cout<<"marking used leafie:"; cout<<res.low[0]<<","<<res.low[1]<<endl; cout<<res.high[0]<<","<<res.high[1]<<endl; */ if(overlap(res.low,res.high,low,high)) { /* every leaf involved in answering the query */ incrementUsed(res.lvl,res.leaf_idx); } if(qcompare(res.high,high) == EQUAL) //we don't need to mark any more leaves, we did it :D return; vector<int> next = getNextLeaf(hist,res.high,high); hist.clear(); res = navigate(next,hist); if(next[0] == REACHED_END) break; /* cout<<"next leafie:"; cout<<res.low[0]<<","<<res.low[1]<<endl; cout<<res.high[0]<<","<<res.high[1]<<endl;*/ //blargh } //end of {while still have leaves in range to mark as used} }