# HG changeset patch # User klao # Date 1075398461 0 # Node ID 67f73b15855d163177803f63bb9365f61e8be0ce # Parent ffaa9448964c098394d290e79243471eab89703e bin_heap.hh: erase metodus empty szebben :) diff -r ffaa9448964c -r 67f73b15855d src/include/bin_heap.hh --- a/src/include/bin_heap.hh Tue Jan 27 21:36:17 2004 +0000 +++ b/src/include/bin_heap.hh Thu Jan 29 17:47:41 2004 +0000 @@ -103,7 +103,7 @@ int size() const { return data.size(); } - bool empty() const { return size() == 0; } + bool empty() const { return data.empty(); } private: static int parent(int i) { return (i-1)/2; } @@ -120,6 +120,17 @@ kim.put(p.first, i); } + void rmidx(int h) { + int n = data.size()-1; + if( h>=0 && h<=n ) { + kim.put(data[h].first, POST_HEAP); + if ( h=0 ) { - kim.put(data[0].first, POST_HEAP); - if ( n>0 ) { - bubble_down(0, data[n], n); - } - data.pop_back(); - } + rmidx(0); + } + + void erase(const Key &k) { + rmidx(kim.get(k)); } const Val get(const Key &k) const {