lemon/bin_heap.h
changeset 1902 e9af75c90c28
parent 1875 98698b69a902
child 1903 f3d24016dad5
     1.1 --- a/lemon/bin_heap.h	Tue Jan 24 16:07:38 2006 +0000
     1.2 +++ b/lemon/bin_heap.h	Wed Jan 25 12:10:18 2006 +0000
     1.3 @@ -267,6 +267,25 @@
     1.4        return state_enum(s);
     1.5      }
     1.6  
     1.7 +    /// \brief Sets the state of the \c item in the heap.
     1.8 +    ///
     1.9 +    /// Sets the state of the \c item in the heap. It can be used to
    1.10 +    /// manually clear the heap when it is important to achive the
    1.11 +    /// better time complexity.
    1.12 +    /// \param i The item.
    1.13 +    /// \param st The state. It should not be \c IN_HEAP. 
    1.14 +    void state(const Item& i, state_enum st) {
    1.15 +      switch (st) {
    1.16 +      case POST_HEAP:
    1.17 +      case PRE_HEAP:
    1.18 +        if (state(i) == IN_HEAP) {
    1.19 +          erase(i);
    1.20 +        }
    1.21 +        index[i] = st;
    1.22 +        break;
    1.23 +      }
    1.24 +    }
    1.25 +
    1.26    }; // class BinHeap
    1.27  
    1.28