Swap function for DescriptorMap
authordeba
Wed, 13 Jul 2005 13:16:57 +0000
changeset 15525c7f270f8e25
parent 1551 2b45f64f6377
child 1553 434f9add42cd
Swap function for DescriptorMap
lemon/graph_utils.h
     1.1 --- a/lemon/graph_utils.h	Tue Jul 12 21:45:39 2005 +0000
     1.2 +++ b/lemon/graph_utils.h	Wed Jul 13 13:16:57 2005 +0000
     1.3 @@ -749,6 +749,18 @@
     1.4  
     1.5    public:
     1.6  
     1.7 +    /// \brief Swaps the position of the two items in the map.
     1.8 +    ///
     1.9 +    /// Swaps the position of the two items in the map.
    1.10 +    void swap(const Item& p, const Item& q) {
    1.11 +      int pi = Map::operator[](p);
    1.12 +      int qi = Map::operator[](q);
    1.13 +      Map::set(p, qi);
    1.14 +      invMap[qi] = p;
    1.15 +      Map::set(q, pi);
    1.16 +      invMap[pi] = q;
    1.17 +    }
    1.18 +
    1.19      /// \brief Gives back the \e descriptor of the item.
    1.20      ///
    1.21      /// Gives back the mutable and unique \e descriptor of the map.
    1.22 @@ -790,7 +802,7 @@
    1.23        /// \brief Size of the map.
    1.24        ///
    1.25        /// Returns the size of the map.
    1.26 -      unsigned size() const {
    1.27 +      int size() const {
    1.28  	return inverted.invMap.size();
    1.29        }
    1.30