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    
     2.1 --- a/lemon/concept/heap.h	Tue Jan 24 16:07:38 2006 +0000
     2.2 +++ b/lemon/concept/heap.h	Wed Jan 25 12:10:18 2006 +0000
     2.3 @@ -152,6 +152,15 @@
     2.4        /// \param i The item.
     2.5        state_enum state(const Item &i) const {}
     2.6  
     2.7 +      /// \brief Sets the state of the \c item in the heap.
     2.8 +      ///
     2.9 +      /// Sets the state of the \c item in the heap. It can be used to
    2.10 +      /// manually clear the heap when it is important to achive the
    2.11 +      /// better time complexity.
    2.12 +      /// \param i The item.
    2.13 +      /// \param st The state. It should not be \c IN_HEAP. 
    2.14 +      void state(const Item& i, state_enum st) {}
    2.15 +
    2.16  
    2.17        template <typename _Heap>
    2.18        struct Constraints {
     3.1 --- a/lemon/fib_heap.h	Tue Jan 24 16:07:38 2006 +0000
     3.2 +++ b/lemon/fib_heap.h	Wed Jan 25 12:10:18 2006 +0000
     3.3 @@ -216,6 +216,25 @@
     3.4        }
     3.5        return state_enum(i);
     3.6      }    
     3.7 +
     3.8 +    /// \brief Sets the state of the \c item in the heap.
     3.9 +    ///
    3.10 +    /// Sets the state of the \c item in the heap. It can be used to
    3.11 +    /// manually clear the heap when it is important to achive the
    3.12 +    /// better time complexity.
    3.13 +    /// \param i The item.
    3.14 +    /// \param st The state. It should not be \c IN_HEAP. 
    3.15 +    void state(const Item& i, state_enum st) {
    3.16 +      switch (st) {
    3.17 +      case POST_HEAP:
    3.18 +      case PRE_HEAP:
    3.19 +        if (state(i) == IN_HEAP) {
    3.20 +          erase(i);
    3.21 +        }
    3.22 +        index[i] = st;
    3.23 +        break;
    3.24 +      }
    3.25 +    }
    3.26      
    3.27    private:
    3.28      
     4.1 --- a/lemon/linear_heap.h	Tue Jan 24 16:07:38 2006 +0000
     4.2 +++ b/lemon/linear_heap.h	Wed Jan 25 12:10:18 2006 +0000
     4.3 @@ -283,6 +283,25 @@
     4.4        return state_enum(idx);
     4.5      }
     4.6  
     4.7 +    /// \brief Sets the state of the \c item in the heap.
     4.8 +    ///
     4.9 +    /// Sets the state of the \c item in the heap. It can be used to
    4.10 +    /// manually clear the heap when it is important to achive the
    4.11 +    /// better time complexity.
    4.12 +    /// \param i The item.
    4.13 +    /// \param st The state. It should not be \c IN_HEAP. 
    4.14 +    void state(const Item& i, state_enum st) {
    4.15 +      switch (st) {
    4.16 +      case POST_HEAP:
    4.17 +      case PRE_HEAP:
    4.18 +        if (state(i) == IN_HEAP) {
    4.19 +          erase(i);
    4.20 +        }
    4.21 +        index[i] = st;
    4.22 +        break;
    4.23 +      }
    4.24 +    }
    4.25 +
    4.26    private:
    4.27  
    4.28      struct LinearItem {
    4.29 @@ -459,6 +478,18 @@
    4.30        return state_enum(idx);
    4.31      }
    4.32  
    4.33 +    void state(const Item& i, state_enum st) {
    4.34 +      switch (st) {
    4.35 +      case POST_HEAP:
    4.36 +      case PRE_HEAP:
    4.37 +        if (state(i) == IN_HEAP) {
    4.38 +          erase(i);
    4.39 +        }
    4.40 +        index[i] = st;
    4.41 +        break;
    4.42 +      }
    4.43 +    }
    4.44 +
    4.45    private:
    4.46  
    4.47      struct LinearItem {
     5.1 --- a/lemon/radix_heap.h	Tue Jan 24 16:07:38 2006 +0000
     5.2 +++ b/lemon/radix_heap.h	Wed Jan 25 12:10:18 2006 +0000
     5.3 @@ -406,6 +406,25 @@
     5.4        return state_enum(s);
     5.5      }
     5.6  
     5.7 +    /// \brief Sets the state of the \c item in the heap.
     5.8 +    ///
     5.9 +    /// Sets the state of the \c item in the heap. It can be used to
    5.10 +    /// manually clear the heap when it is important to achive the
    5.11 +    /// better time complexity.
    5.12 +    /// \param i The item.
    5.13 +    /// \param st The state. It should not be \c IN_HEAP. 
    5.14 +    void state(const Item& i, state_enum st) {
    5.15 +      switch (st) {
    5.16 +      case POST_HEAP:
    5.17 +      case PRE_HEAP:
    5.18 +        if (state(i) == IN_HEAP) {
    5.19 +          erase(i);
    5.20 +        }
    5.21 +        index[i] = st;
    5.22 +        break;
    5.23 +      }
    5.24 +    }
    5.25 +
    5.26    }; // class RadixHeap
    5.27  
    5.28  } // namespace lemon