lemon/bits/array_map.h
changeset 2031 080d51024ac5
parent 1999 2ff283124dfc
child 2046 66d160810c0a
equal deleted inserted replaced
13:04deed3496b5 14:2a62061ac0c6
    21 
    21 
    22 #include <memory>
    22 #include <memory>
    23 
    23 
    24 #include <lemon/bits/traits.h>
    24 #include <lemon/bits/traits.h>
    25 #include <lemon/bits/alteration_notifier.h>
    25 #include <lemon/bits/alteration_notifier.h>
       
    26 #include <lemon/concept_check.h>
       
    27 #include <lemon/concept/maps.h>
    26 
    28 
    27 /// \ingroup graphbits
    29 /// \ingroup graphbits
    28 /// \file
    30 /// \file
    29 /// \brief Graph map based on the array storage.
    31 /// \brief Graph map based on the array storage.
    30 
    32 
   117 	int id = notifier->id(it);;
   119 	int id = notifier->id(it);;
   118 	allocator.construct(&(values[id]), copy.values[id]);
   120 	allocator.construct(&(values[id]), copy.values[id]);
   119       }
   121       }
   120     }
   122     }
   121 
   123 
       
   124     /// \brief Assign operator.
       
   125     ///
       
   126     /// This operator assigns for each item in the map the
       
   127     /// value mapped to the same item in the copied map.  
       
   128     /// The parameter map should be indiced with the same
       
   129     /// itemset because this assign operator does not change
       
   130     /// the container of the map. 
       
   131     ArrayMap& operator=(const ArrayMap& cmap) {
       
   132       return operator=<ArrayMap>(cmap);
       
   133     }
       
   134 
       
   135 
       
   136     /// \brief Template assign operator.
       
   137     ///
       
   138     /// The given parameter should be conform to the ReadMap
       
   139     /// concecpt and could be indiced by the current item set of
       
   140     /// the NodeMap. In this case the value for each item
       
   141     /// is assigned by the value of the given ReadMap. 
       
   142     template <typename CMap>
       
   143     ArrayMap& operator=(const CMap& cmap) {
       
   144       checkConcept<concept::ReadMap<Key, _Value>, CMap>();
       
   145       const typename Parent::Notifier* notifier = Parent::getNotifier();
       
   146       Item it;
       
   147       for (notifier->first(it); it != INVALID; notifier->next(it)) {
       
   148         set(it, cmap[it]);
       
   149       }
       
   150       return *this;
       
   151     }
       
   152 
   122     /// \brief The destructor of the map.
   153     /// \brief The destructor of the map.
   123     ///     
   154     ///     
   124     /// The destructor of the map.
   155     /// The destructor of the map.
   125     virtual ~ArrayMap() {      
   156     virtual ~ArrayMap() {      
   126       if (attached()) {
   157       if (attached()) {
   127 	clear();
   158 	clear();
   128 	detach();
   159 	detach();
   129       }
   160       }
   130     }
   161     }
   131 		
   162 		
   132   private:
       
   133 
       
   134     ArrayMap& operator=(const ArrayMap&);
       
   135 
       
   136   protected:
   163   protected:
   137 
   164 
   138     using Parent::attach;
   165     using Parent::attach;
   139     using Parent::detach;
   166     using Parent::detach;
   140     using Parent::attached;
   167     using Parent::attached;