lemon/bin_heap.h
changeset 1773 ea5927cef15c
parent 1435 8e85e6bbefdf
child 1834 0a14e1ae45a1
equal deleted inserted replaced
0:2dcc464eab47 1:9f93bc53e267
   107     /// \brief Checks if the heap stores no items.
   107     /// \brief Checks if the heap stores no items.
   108     ///
   108     ///
   109     /// Returns \c true if and only if the heap stores no items.
   109     /// Returns \c true if and only if the heap stores no items.
   110     bool empty() const { return data.empty(); }
   110     bool empty() const { return data.empty(); }
   111 
   111 
       
   112     /// \brief Make empty this heap.
       
   113     /// 
       
   114     /// Make empty this heap.
       
   115     void clear() { 
       
   116       for (int i = 0; i < (int)data.size(); ++i) {
       
   117 	iim.set(data[i].first, POST_HEAP);
       
   118       }
       
   119       data.clear(); 
       
   120     }
       
   121 
   112   private:
   122   private:
   113     static int parent(int i) { return (i-1)/2; }
   123     static int parent(int i) { return (i-1)/2; }
   114     static int second_child(int i) { return 2*i+2; }
   124     static int second_child(int i) { return 2*i+2; }
   115     bool less(const PairType &p1, const PairType &p2) const {
   125     bool less(const PairType &p1, const PairType &p2) const {
   116       return comp(p1.second, p2.second);
   126       return comp(p1.second, p2.second);