Changeset 41:67f73b15855d in lemon-0.x for src/include
- Timestamp:
- 01/29/04 18:47:41 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@56
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/include/bin_heap.hh
r39 r41 104 104 105 105 int size() const { return data.size(); } 106 bool empty() const { return size() == 0; }106 bool empty() const { return data.empty(); } 107 107 108 108 private: … … 121 121 } 122 122 123 void rmidx(int h) { 124 int n = data.size()-1; 125 if( h>=0 && h<=n ) { 126 kim.put(data[h].first, POST_HEAP); 127 if ( h<n ) { 128 bubble_down(h, data[n], n); 129 } 130 data.pop_back(); 131 } 132 } 133 123 134 public: 124 135 void push(const PairType &p) { … … 139 150 140 151 void pop() { 141 int n = data.size()-1; 142 if( n>=0 ) { 143 kim.put(data[0].first, POST_HEAP); 144 if ( n>0 ) { 145 bubble_down(0, data[n], n); 146 } 147 data.pop_back(); 148 } 152 rmidx(0); 153 } 154 155 void erase(const Key &k) { 156 rmidx(kim.get(k)); 149 157 } 150 158
Note: See TracChangeset
for help on using the changeset viewer.