src/lemon/map_utils.h
changeset 1233 f3d856bf1ebf
parent 1199 19eae67d97d5
child 1237 2414b5ab7684
equal deleted inserted replaced
3:e8544cc4d9c9 4:a43d1a1fcdb0
    11  * This software is provided "AS IS" with no warranty of any kind,
    11  * This software is provided "AS IS" with no warranty of any kind,
    12  * express or implied, and with no claim as to its suitability for any
    12  * express or implied, and with no claim as to its suitability for any
    13  * purpose.
    13  * purpose.
    14  *
    14  *
    15  */
    15  */
       
    16 
    16 
    17 
    17 ///\ingroup mutils
    18 ///\ingroup mutils
    18 ///\file
    19 ///\file
    19 ///\brief Map utilities.
    20 ///\brief Map utilities.
    20 
    21 
   189     /// Build the unique map. It is called by the
   190     /// Build the unique map. It is called by the
   190     /// \c AlterationNotifier.
   191     /// \c AlterationNotifier.
   191     virtual void build() {
   192     virtual void build() {
   192       Map::build();
   193       Map::build();
   193       Item it;
   194       Item it;
   194       for (getGraph()->first(it); it != INVALID; getGraph()->next(it)) {
   195       const Graph* graph = Map::getGraph(); 
       
   196       for (graph->first(it); it != INVALID; graph->next(it)) {
   195 	Map::set(it, invMap.size());
   197 	Map::set(it, invMap.size());
   196 	invMap.push_back(it);	
   198 	invMap.push_back(it);	
   197       }      
   199       }      
   198     }
   200     }
   199     
   201     
   240     ///
   242     ///
   241     /// The class represents the inverse of the map.
   243     /// The class represents the inverse of the map.
   242     /// \see inverse()
   244     /// \see inverse()
   243     class InverseMap {
   245     class InverseMap {
   244     protected:
   246     protected:
   245       InverseMap(const Graph& _graph) : graph(_graph) {}
   247       InverseMap(const Graph& _graph) : graph(&_graph) {}
   246     public:
   248     public:
   247       /// \brief Gives back the given item by its id.
   249       /// \brief Gives back the given item by its id.
   248       ///
   250       ///
   249       /// Gives back the given item by its id.
   251       /// Gives back the given item by its id.
   250       /// 
   252       /// 
   251       Item operator[](int id) const { return graph->fromId(id, Item());}
   253       Item operator[](int id) const { return graph->fromId(id, Item());}
   252     private:
   254     private:
   253       Graph* graph;
   255       const Graph* graph;
   254     };
   256     };
   255 
   257 
   256     /// \brief Constructor.
   258     /// \brief Constructor.
   257     ///
   259     ///
   258     /// Constructor for creating id map.
   260     /// Constructor for creating id map.
   271   private:
   273   private:
   272     const Graph* graph;
   274     const Graph* graph;
   273 
   275 
   274   };
   276   };
   275 
   277 
   276 
       
   277 }
   278 }
   278 
   279 
   279 #endif
   280 #endif