Clear for unionfinds
authordeba
Fri, 20 Apr 2007 14:06:08 +0000
changeset 2427d40c31b08d6f
parent 2426 6e1027a05d73
child 2428 c06e86364234
Clear for unionfinds
lemon/unionfind.h
     1.1 --- a/lemon/unionfind.h	Thu Apr 19 15:14:34 2007 +0000
     1.2 +++ b/lemon/unionfind.h	Fri Apr 20 14:06:08 2007 +0000
     1.3 @@ -101,6 +101,13 @@
     1.4        return repIndex(index[a]);
     1.5      }
     1.6  
     1.7 +    /// \brief Clears the union-find data structure
     1.8 +    ///
     1.9 +    /// Erase each item from the data structure.
    1.10 +    void clear() {
    1.11 +      items.clear();
    1.12 +    }
    1.13 +
    1.14      /// \brief Inserts a new element into the structure.
    1.15      ///
    1.16      /// This method inserts a new element into the data structure. 
    1.17 @@ -285,6 +292,14 @@
    1.18        items.push_back(t);
    1.19      }
    1.20  
    1.21 +    /// \brief Clears the union-find data structure
    1.22 +    ///
    1.23 +    /// Erase each item from the data structure.
    1.24 +    void clear() {
    1.25 +      items.clear();
    1.26 +      firstClass = -1;
    1.27 +    }
    1.28 +
    1.29      /// \brief Finds the leader of the component of the given element.
    1.30      ///
    1.31      /// The method returns the leader of the component of the given element.