Index: lemon/bin_heap.h
===================================================================
--- lemon/bin_heap.h	(revision 1875)
+++ lemon/bin_heap.h	(revision 1902)
@@ -268,4 +268,23 @@
     }
 
+    /// \brief Sets the state of the \c item in the heap.
+    ///
+    /// Sets the state of the \c item in the heap. It can be used to
+    /// manually clear the heap when it is important to achive the
+    /// better time complexity.
+    /// \param i The item.
+    /// \param st The state. It should not be \c IN_HEAP. 
+    void state(const Item& i, state_enum st) {
+      switch (st) {
+      case POST_HEAP:
+      case PRE_HEAP:
+        if (state(i) == IN_HEAP) {
+          erase(i);
+        }
+        index[i] = st;
+        break;
+      }
+    }
+
   }; // class BinHeap
 
Index: lemon/concept/heap.h
===================================================================
--- lemon/concept/heap.h	(revision 1875)
+++ lemon/concept/heap.h	(revision 1902)
@@ -153,4 +153,13 @@
       state_enum state(const Item &i) const {}
 
+      /// \brief Sets the state of the \c item in the heap.
+      ///
+      /// Sets the state of the \c item in the heap. It can be used to
+      /// manually clear the heap when it is important to achive the
+      /// better time complexity.
+      /// \param i The item.
+      /// \param st The state. It should not be \c IN_HEAP. 
+      void state(const Item& i, state_enum st) {}
+
 
       template <typename _Heap>
Index: lemon/fib_heap.h
===================================================================
--- lemon/fib_heap.h	(revision 1875)
+++ lemon/fib_heap.h	(revision 1902)
@@ -217,4 +217,23 @@
       return state_enum(i);
     }    
+
+    /// \brief Sets the state of the \c item in the heap.
+    ///
+    /// Sets the state of the \c item in the heap. It can be used to
+    /// manually clear the heap when it is important to achive the
+    /// better time complexity.
+    /// \param i The item.
+    /// \param st The state. It should not be \c IN_HEAP. 
+    void state(const Item& i, state_enum st) {
+      switch (st) {
+      case POST_HEAP:
+      case PRE_HEAP:
+        if (state(i) == IN_HEAP) {
+          erase(i);
+        }
+        index[i] = st;
+        break;
+      }
+    }
     
   private:
Index: lemon/linear_heap.h
===================================================================
--- lemon/linear_heap.h	(revision 1875)
+++ lemon/linear_heap.h	(revision 1902)
@@ -284,4 +284,23 @@
     }
 
+    /// \brief Sets the state of the \c item in the heap.
+    ///
+    /// Sets the state of the \c item in the heap. It can be used to
+    /// manually clear the heap when it is important to achive the
+    /// better time complexity.
+    /// \param i The item.
+    /// \param st The state. It should not be \c IN_HEAP. 
+    void state(const Item& i, state_enum st) {
+      switch (st) {
+      case POST_HEAP:
+      case PRE_HEAP:
+        if (state(i) == IN_HEAP) {
+          erase(i);
+        }
+        index[i] = st;
+        break;
+      }
+    }
+
   private:
 
@@ -460,4 +479,16 @@
     }
 
+    void state(const Item& i, state_enum st) {
+      switch (st) {
+      case POST_HEAP:
+      case PRE_HEAP:
+        if (state(i) == IN_HEAP) {
+          erase(i);
+        }
+        index[i] = st;
+        break;
+      }
+    }
+
   private:
 
Index: lemon/radix_heap.h
===================================================================
--- lemon/radix_heap.h	(revision 1875)
+++ lemon/radix_heap.h	(revision 1902)
@@ -407,4 +407,23 @@
     }
 
+    /// \brief Sets the state of the \c item in the heap.
+    ///
+    /// Sets the state of the \c item in the heap. It can be used to
+    /// manually clear the heap when it is important to achive the
+    /// better time complexity.
+    /// \param i The item.
+    /// \param st The state. It should not be \c IN_HEAP. 
+    void state(const Item& i, state_enum st) {
+      switch (st) {
+      case POST_HEAP:
+      case PRE_HEAP:
+        if (state(i) == IN_HEAP) {
+          erase(i);
+        }
+        index[i] = st;
+        break;
+      }
+    }
+
   }; // class RadixHeap
 
