src/lemon/array_map.h
changeset 1146 ebab0e5ec8b2
parent 988 aa19ca32d9b0
child 1164 80bb73097736
equal deleted inserted replaced
6:19f6763ba155 7:e2d19f4d79f3
    41 
    41 
    42   template <typename _Graph, 
    42   template <typename _Graph, 
    43 	    typename _Item,
    43 	    typename _Item,
    44 	    typename _ItemIt,
    44 	    typename _ItemIt,
    45 	    typename _Value>
    45 	    typename _Value>
    46   class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase {
    46   class ArrayMap : public AlterationNotifier<_Item>::ObserverBase {
    47 
    47 
    48   public:
    48   public:
    49 		
    49 		
    50     /// The graph type of the maps. 
    50     /// The graph type of the maps. 
    51     typedef _Graph Graph;
    51     typedef _Graph Graph;
    52     /// The key type of the maps.
    52     /// The key type of the maps.
    53     typedef _Item Key;
    53     typedef _Item Key;
    54 
    54 
    55     typedef AlterationObserverRegistry<_Item> Registry;
    55     typedef AlterationNotifier<_Item> Registry;
    56 
    56 
    57   private:
    57   private:
    58     /// The iterator to iterate on the keys.
    58     /// The iterator to iterate on the keys.
    59     typedef _ItemIt KeyIt;
    59     typedef _ItemIt KeyIt;
    60 
    60 
    86   public:
    86   public:
    87 
    87 
    88     /** Graph and Registry initialized map constructor.
    88     /** Graph and Registry initialized map constructor.
    89      */
    89      */
    90     ArrayMap(const Graph& _g) : graph(&_g) {
    90     ArrayMap(const Graph& _g) : graph(&_g) {
    91       attach(_g.getObserverRegistry(_Item()));
    91       attach(_g.getNotifier(_Item()));
    92       allocate_memory();
    92       allocate_memory();
    93       for (KeyIt it(*graph); it != INVALID; ++it) {
    93       for (KeyIt it(*graph); it != INVALID; ++it) {
    94 	int id = graph->id(it);;
    94 	int id = graph->id(it);;
    95 	allocator.construct(&(values[id]), Value());
    95 	allocator.construct(&(values[id]), Value());
    96       }								
    96       }								
    99     /// Constructor to use default value to initialize the map. 
    99     /// Constructor to use default value to initialize the map. 
   100 
   100 
   101     /// It constrates a map and initialize all of the the map. 
   101     /// It constrates a map and initialize all of the the map. 
   102 
   102 
   103     ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) {
   103     ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) {
   104       attach(_g.getObserverRegistry(_Item()));
   104       attach(_g.getNotifier(_Item()));
   105       allocate_memory();
   105       allocate_memory();
   106       for (KeyIt it(*graph); it != INVALID; ++it) {
   106       for (KeyIt it(*graph); it != INVALID; ++it) {
   107 	int id = graph->id(it);;
   107 	int id = graph->id(it);;
   108 	allocator.construct(&(values[id]), _v);
   108 	allocator.construct(&(values[id]), _v);
   109       }								
   109       }								
   334     typedef ArrayMappableGraphExtender<_Base> Graph;
   334     typedef ArrayMappableGraphExtender<_Base> Graph;
   335     typedef _Base Parent;
   335     typedef _Base Parent;
   336 
   336 
   337     typedef typename Parent::Node Node;
   337     typedef typename Parent::Node Node;
   338     typedef typename Parent::NodeIt NodeIt;
   338     typedef typename Parent::NodeIt NodeIt;
   339     typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
   339     typedef typename Parent::NodeNotifier NodeObserverRegistry;
   340 
   340 
   341     typedef typename Parent::Edge Edge;
   341     typedef typename Parent::Edge Edge;
   342     typedef typename Parent::EdgeIt EdgeIt;
   342     typedef typename Parent::EdgeIt EdgeIt;
   343     typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
   343     typedef typename Parent::EdgeNotifier EdgeObserverRegistry;
   344 
   344 
   345     
   345     
   346 
   346 
   347     template <typename _Value>
   347     template <typename _Value>
   348     class NodeMap : public ArrayMap<Graph, Node, NodeIt, _Value> {
   348     class NodeMap : public ArrayMap<Graph, Node, NodeIt, _Value> {