src/lemon/vector_map.h
changeset 1286 692948b894e8
parent 1164 80bb73097736
equal deleted inserted replaced
9:701aa92509a9 10:4b5d00d0854d
    18 #define LEMON_VECTOR_MAP_H
    18 #define LEMON_VECTOR_MAP_H
    19 
    19 
    20 #include <vector>
    20 #include <vector>
    21 #include <algorithm>
    21 #include <algorithm>
    22 
    22 
       
    23 #include <lemon/utility.h>
       
    24 #include <lemon/map_iterator.h>
    23 #include <lemon/alteration_notifier.h>
    25 #include <lemon/alteration_notifier.h>
    24 
    26 
    25 ///\ingroup graphmaps
    27 ///\ingroup graphmaps
    26 ///\file
    28 ///\file
    27 ///\brief Vector based graph maps.
    29 ///\brief Vector based graph maps.
    42   /// \param Value The value type of the map.
    44   /// \param Value The value type of the map.
    43   /// 
    45   /// 
    44   /// \author Balazs Dezso
    46   /// \author Balazs Dezso
    45   	
    47   	
    46 
    48 
    47   template <typename _Graph, 
    49   template <
    48 	    typename _Item,
    50     typename _Graph, 
    49 	    typename _Value>
    51     typename _Item,    
       
    52     typename _Value
       
    53     >
    50   class VectorMap : public AlterationNotifier<_Item>::ObserverBase {
    54   class VectorMap : public AlterationNotifier<_Item>::ObserverBase {
    51   public:
    55   public:
    52 		
    56 		
    53     /// The graph type of the map. 
    57     /// The graph type of the map. 
    54     typedef _Graph Graph;
    58     typedef _Graph Graph;
    80     typedef const Value ConstValue;
    84     typedef const Value ConstValue;
    81     /// The const reference type of the map;
    85     /// The const reference type of the map;
    82     typedef typename Container::const_reference ConstReference;
    86     typedef typename Container::const_reference ConstReference;
    83     /// The pointer type of the map;
    87     /// The pointer type of the map;
    84     typedef typename Container::const_pointer ConstPointer;
    88     typedef typename Container::const_pointer ConstPointer;
       
    89 
       
    90     typedef True FullTypeTag;
    85 
    91 
    86     /// Constructor to attach the new map into the registry.
    92     /// Constructor to attach the new map into the registry.
    87 
    93 
    88     /// It construates a map and attachs it into the registry.
    94     /// It construates a map and attachs it into the registry.
    89     /// It adds all the items of the graph to the map.
    95     /// It adds all the items of the graph to the map.
   203     /// It erase all items from the map. It called by the observer registry
   209     /// It erase all items from the map. It called by the observer registry
   204     /// and it overrides the clear() member function of the observer base.     
   210     /// and it overrides the clear() member function of the observer base.     
   205     void clear() { 
   211     void clear() { 
   206       container.clear();
   212       container.clear();
   207     }
   213     }
   208 
   214     
   209   private:
   215   private:
   210 		
   216 		
   211     Container container;
   217     Container container;
   212     const Graph *graph;
   218     const Graph *graph;
   213 
   219 
   230     typedef typename Parent::EdgeIt EdgeIt;
   236     typedef typename Parent::EdgeIt EdgeIt;
   231     typedef typename Parent::EdgeIdMap EdgeIdMap;
   237     typedef typename Parent::EdgeIdMap EdgeIdMap;
   232     typedef typename Parent::EdgeNotifier EdgeObserverRegistry;
   238     typedef typename Parent::EdgeNotifier EdgeObserverRegistry;
   233 
   239 
   234     
   240     
   235 
       
   236     template <typename _Value>
   241     template <typename _Value>
   237     class NodeMap : public VectorMap<Graph, Node, _Value> {
   242     class NodeMap : 
       
   243       public IterableMapExtender<VectorMap<Graph, Node, _Value> > {
   238     public:
   244     public:
   239       typedef VectorMappableGraphExtender<_Base> Graph;
   245       typedef VectorMappableGraphExtender<_Base> Graph;
   240 
   246 
   241       typedef typename Graph::Node Node;
   247       typedef typename Graph::Node Node;
   242 
   248 
   243       typedef VectorMap<Graph, Node, _Value> Parent;
   249       typedef IterableMapExtender<VectorMap<Graph, Node, _Value> > Parent;
   244 
   250 
   245       //typedef typename Parent::Graph Graph;
   251       //typedef typename Parent::Graph Graph;
   246       typedef typename Parent::Value Value;
   252       typedef typename Parent::Value Value;
   247 
   253 
   248       NodeMap(const Graph& g) 
   254       NodeMap(const Graph& g) 
   251 	: Parent(g, v) {}
   257 	: Parent(g, v) {}
   252 
   258 
   253     };
   259     };
   254 
   260 
   255     template <typename _Value>
   261     template <typename _Value>
   256     class EdgeMap : public VectorMap<Graph, Edge, _Value> {
   262     class EdgeMap 
       
   263       : public IterableMapExtender<VectorMap<Graph, Edge, _Value> > {
   257     public:
   264     public:
   258       typedef VectorMappableGraphExtender<_Base> Graph;
   265       typedef VectorMappableGraphExtender<_Base> Graph;
   259 
   266 
   260       typedef typename Graph::Edge Edge;
   267       typedef typename Graph::Edge Edge;
   261 
   268 
   262       typedef VectorMap<Graph, Edge, _Value> Parent;
   269       typedef IterableMapExtender<VectorMap<Graph, Edge, _Value> > Parent;
   263 
   270 
   264       //typedef typename Parent::Graph Graph;
   271       //typedef typename Parent::Graph Graph;
   265       typedef typename Parent::Value Value;
   272       typedef typename Parent::Value Value;
   266 
   273 
   267       EdgeMap(const Graph& g) 
   274       EdgeMap(const Graph& g)