lemon/maps.h
changeset 720 6e8c27ee9079
parent 684 7b1a6e963018
child 721 99124ea4f048
equal deleted inserted replaced
33:d3ddbcf08d47 39:280d2394b1bd
  1824   ///    delete other nodes).
  1824   ///    delete other nodes).
  1825   ///
  1825   ///
  1826   /// Using this map you get access (i.e. can read) the inner id values of
  1826   /// Using this map you get access (i.e. can read) the inner id values of
  1827   /// the items stored in the graph, which is returned by the \c id()
  1827   /// the items stored in the graph, which is returned by the \c id()
  1828   /// function of the graph. This map can be inverted with its member
  1828   /// function of the graph. This map can be inverted with its member
  1829   /// class \c InverseMap or with the \c operator() member.
  1829   /// class \c InverseMap or with the \c operator()() member.
  1830   ///
  1830   ///
  1831   /// \tparam GR The graph type.
  1831   /// \tparam GR The graph type.
  1832   /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
  1832   /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
  1833   /// \c GR::Edge).
  1833   /// \c GR::Edge).
  1834   ///
  1834   ///
  2030     /// If there are more items with the same associated value,
  2030     /// If there are more items with the same associated value,
  2031     /// only one of them is returned.
  2031     /// only one of them is returned.
  2032     Key operator()(const Value& val) const {
  2032     Key operator()(const Value& val) const {
  2033       typename Container::const_iterator it = _inv_map.find(val);
  2033       typename Container::const_iterator it = _inv_map.find(val);
  2034       return it != _inv_map.end() ? it->second : INVALID;
  2034       return it != _inv_map.end() ? it->second : INVALID;
       
  2035     }
       
  2036     
       
  2037     /// \brief Returns the number of items with the given value.
       
  2038     ///
       
  2039     /// This function returns the number of items with the given value
       
  2040     /// associated with it.
       
  2041     int count(const Value &val) const {
       
  2042       return _inv_map.count(val);
  2035     }
  2043     }
  2036 
  2044 
  2037   protected:
  2045   protected:
  2038 
  2046 
  2039     /// \brief Erase the key from the map and the inverse map.
  2047     /// \brief Erase the key from the map and the inverse map.
  2120       return InverseMap(*this);
  2128       return InverseMap(*this);
  2121     }
  2129     }
  2122 
  2130 
  2123   };
  2131   };
  2124 
  2132 
  2125   /// \brief Provides continuous and unique ID for the
  2133   /// \brief Provides continuous and unique id for the
  2126   /// items of a graph.
  2134   /// items of a graph.
  2127   ///
  2135   ///
  2128   /// RangeIdMap provides a unique and continuous
  2136   /// RangeIdMap provides a unique and continuous
  2129   /// ID for each item of a given type (\c Node, \c Arc or
  2137   /// id for each item of a given type (\c Node, \c Arc or
  2130   /// \c Edge) in a graph. This id is
  2138   /// \c Edge) in a graph. This id is
  2131   ///  - \b unique: different items get different ids,
  2139   ///  - \b unique: different items get different ids,
  2132   ///  - \b continuous: the range of the ids is the set of integers
  2140   ///  - \b continuous: the range of the ids is the set of integers
  2133   ///    between 0 and \c n-1, where \c n is the number of the items of
  2141   ///    between 0 and \c n-1, where \c n is the number of the items of
  2134   ///    this type (\c Node, \c Arc or \c Edge).
  2142   ///    this type (\c Node, \c Arc or \c Edge).
  2135   ///  - So, the ids can change when deleting an item of the same type.
  2143   ///  - So, the ids can change when deleting an item of the same type.
  2136   ///
  2144   ///
  2137   /// Thus this id is not (necessarily) the same as what can get using
  2145   /// Thus this id is not (necessarily) the same as what can get using
  2138   /// the \c id() function of the graph or \ref IdMap.
  2146   /// the \c id() function of the graph or \ref IdMap.
  2139   /// This map can be inverted with its member class \c InverseMap,
  2147   /// This map can be inverted with its member class \c InverseMap,
  2140   /// or with the \c operator() member.
  2148   /// or with the \c operator()() member.
  2141   ///
  2149   ///
  2142   /// \tparam GR The graph type.
  2150   /// \tparam GR The graph type.
  2143   /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
  2151   /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or
  2144   /// \c GR::Edge).
  2152   /// \c GR::Edge).
  2145   ///
  2153   ///