equal
deleted
inserted
replaced
265 if( s>=0 ) |
265 if( s>=0 ) |
266 s=0; |
266 s=0; |
267 return state_enum(s); |
267 return state_enum(s); |
268 } |
268 } |
269 |
269 |
|
270 /// \brief Sets the state of the \c item in the heap. |
|
271 /// |
|
272 /// Sets the state of the \c item in the heap. It can be used to |
|
273 /// manually clear the heap when it is important to achive the |
|
274 /// better time complexity. |
|
275 /// \param i The item. |
|
276 /// \param st The state. It should not be \c IN_HEAP. |
|
277 void state(const Item& i, state_enum st) { |
|
278 switch (st) { |
|
279 case POST_HEAP: |
|
280 case PRE_HEAP: |
|
281 if (state(i) == IN_HEAP) { |
|
282 erase(i); |
|
283 } |
|
284 index[i] = st; |
|
285 break; |
|
286 } |
|
287 } |
|
288 |
270 }; // class BinHeap |
289 }; // class BinHeap |
271 |
290 |
272 |
291 |
273 template <typename K, typename V, typename M, typename C> |
292 template <typename K, typename V, typename M, typename C> |
274 int BinHeap<K,V,M,C>::bubble_up(int hole, PairType p) { |
293 int BinHeap<K,V,M,C>::bubble_up(int hole, PairType p) { |