# HG changeset patch # User deba # Date 1121260617 0 # Node ID 5c7f270f8e25c814426d8ce0376a9e553925226a # Parent 2b45f64f6377025c413871f0cf9731a2211a4652 Swap function for DescriptorMap diff -r 2b45f64f6377 -r 5c7f270f8e25 lemon/graph_utils.h --- a/lemon/graph_utils.h Tue Jul 12 21:45:39 2005 +0000 +++ b/lemon/graph_utils.h Wed Jul 13 13:16:57 2005 +0000 @@ -749,6 +749,18 @@ public: + /// \brief Swaps the position of the two items in the map. + /// + /// Swaps the position of the two items in the map. + void swap(const Item& p, const Item& q) { + int pi = Map::operator[](p); + int qi = Map::operator[](q); + Map::set(p, qi); + invMap[qi] = p; + Map::set(q, pi); + invMap[pi] = q; + } + /// \brief Gives back the \e descriptor of the item. /// /// Gives back the mutable and unique \e descriptor of the map. @@ -790,7 +802,7 @@ /// \brief Size of the map. /// /// Returns the size of the map. - unsigned size() const { + int size() const { return inverted.invMap.size(); }