lemon/bits/array_map.h
changeset 815 aef153f430e1
parent 503 9605e051942f
child 877 141f9c0db4a3
equal deleted inserted replaced
7:9f6a7b8ab60e 8:9302faa9d01a
    45   template <typename _Graph, typename _Item, typename _Value>
    45   template <typename _Graph, typename _Item, typename _Value>
    46   class ArrayMap
    46   class ArrayMap
    47     : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
    47     : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
    48   public:
    48   public:
    49     // The graph type.
    49     // The graph type.
    50     typedef _Graph Graph;
    50     typedef _Graph GraphType;
    51     // The item type.
    51     // The item type.
    52     typedef _Item Item;
    52     typedef _Item Item;
    53     // The reference map tag.
    53     // The reference map tag.
    54     typedef True ReferenceMapTag;
    54     typedef True ReferenceMapTag;
    55 
    55 
    61     // The const reference type of the map.
    61     // The const reference type of the map.
    62     typedef const _Value& ConstReference;
    62     typedef const _Value& ConstReference;
    63     // The reference type of the map.
    63     // The reference type of the map.
    64     typedef _Value& Reference;
    64     typedef _Value& Reference;
    65 
    65 
       
    66     // The map type.
       
    67     typedef ArrayMap Map;
       
    68 
    66     // The notifier type.
    69     // The notifier type.
    67     typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
    70     typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
    68 
    71 
       
    72   private:
       
    73   
    69     // The MapBase of the Map which imlements the core regisitry function.
    74     // The MapBase of the Map which imlements the core regisitry function.
    70     typedef typename Notifier::ObserverBase Parent;
    75     typedef typename Notifier::ObserverBase Parent;
    71 
    76 
    72   private:
       
    73     typedef std::allocator<Value> Allocator;
    77     typedef std::allocator<Value> Allocator;
    74 
    78 
    75   public:
    79   public:
    76 
    80 
    77     // \brief Graph initialized map constructor.
    81     // \brief Graph initialized map constructor.
    78     //
    82     //
    79     // Graph initialized map constructor.
    83     // Graph initialized map constructor.
    80     explicit ArrayMap(const Graph& graph) {
    84     explicit ArrayMap(const GraphType& graph) {
    81       Parent::attach(graph.notifier(Item()));
    85       Parent::attach(graph.notifier(Item()));
    82       allocate_memory();
    86       allocate_memory();
    83       Notifier* nf = Parent::notifier();
    87       Notifier* nf = Parent::notifier();
    84       Item it;
    88       Item it;
    85       for (nf->first(it); it != INVALID; nf->next(it)) {
    89       for (nf->first(it); it != INVALID; nf->next(it)) {
    89     }
    93     }
    90 
    94 
    91     // \brief Constructor to use default value to initialize the map.
    95     // \brief Constructor to use default value to initialize the map.
    92     //
    96     //
    93     // It constructs a map and initialize all of the the map.
    97     // It constructs a map and initialize all of the the map.
    94     ArrayMap(const Graph& graph, const Value& value) {
    98     ArrayMap(const GraphType& graph, const Value& value) {
    95       Parent::attach(graph.notifier(Item()));
    99       Parent::attach(graph.notifier(Item()));
    96       allocate_memory();
   100       allocate_memory();
    97       Notifier* nf = Parent::notifier();
   101       Notifier* nf = Parent::notifier();
    98       Item it;
   102       Item it;
    99       for (nf->first(it); it != INVALID; nf->next(it)) {
   103       for (nf->first(it); it != INVALID; nf->next(it)) {