lemon/concepts/maps.h
changeset 45 bc69cdfe171c
parent 28 e337bdf46777
child 39 0a01d811071f
child 48 93ae269876de
equal deleted inserted replaced
1:cc4592f0a275 2:faa65726ce79
    39     ///
    39     ///
    40     template<typename K, typename T>
    40     template<typename K, typename T>
    41     class ReadMap
    41     class ReadMap
    42     {
    42     {
    43     public:
    43     public:
    44       /// Map's key type.
    44       /// The key type of the map.
    45       typedef K Key;    
    45       typedef K Key;    
    46       /// Map's value type. (The type of objects associated with the keys).
    46       /// The value type of the map. (The type of objects associated with the keys).
    47       typedef T Value;
    47       typedef T Value;
    48 
    48 
    49       /// Returns the value associated with a key.
    49       /// Returns the value associated with a key.
    50 
    50 
    51       /// \bug Value shouldn't need to be default constructible.
    51       /// \bug Value shouldn't need to be default constructible.
    79     ///
    79     ///
    80     template<typename K, typename T>
    80     template<typename K, typename T>
    81     class WriteMap
    81     class WriteMap
    82     {
    82     {
    83     public:
    83     public:
    84       /// Map's key type.
    84       /// The key type of the map.
    85       typedef K Key;    
    85       typedef K Key;    
    86       /// Map's value type. (The type of objects associated with the keys).
    86       /// The value type of the map. (The type of objects associated with the keys).
    87       typedef T Value;
    87       typedef T Value;
    88 
    88 
    89       /// Sets the value associated with a key.
    89       /// Sets the value associated with a key.
    90       void set(const Key &,const Value &) {}
    90       void set(const Key &,const Value &) {}
    91 
    91 
   117     
   117     
   118     /// Read/writable map concept.
   118     /// Read/writable map concept.
   119     ///
   119     ///
   120     template<typename K, typename T>
   120     template<typename K, typename T>
   121     class ReadWriteMap : public ReadMap<K,T>,
   121     class ReadWriteMap : public ReadMap<K,T>,
   122 			    public WriteMap<K,T>
   122 			 public WriteMap<K,T>
   123     {
   123     {
   124     public:
   124     public:
   125       /// Map's key type.
   125       /// The key type of the map.
   126       typedef K Key;    
   126       typedef K Key;    
   127       /// Map's value type. (The type of objects associated with the keys).
   127       /// The value type of the map. (The type of objects associated with the keys).
   128       typedef T Value;
   128       typedef T Value;
   129 
   129 
   130       /// Returns the value associated with a key.
   130       /// Returns the value associated with a key.
   131       Value operator[](const Key &) const {return Value();}
   131       Value operator[](const Key &) const {return Value();}
   132       /// Sets the value associated with a key.
   132       /// Sets the value associated with a key.
   150     class ReferenceMap : public ReadWriteMap<K,T>
   150     class ReferenceMap : public ReadWriteMap<K,T>
   151     {
   151     {
   152     public:
   152     public:
   153       /// Tag for reference maps.
   153       /// Tag for reference maps.
   154       typedef True ReferenceMapTag;
   154       typedef True ReferenceMapTag;
   155       /// Map's key type.
   155       /// The key type of the map.
   156       typedef K Key;    
   156       typedef K Key;    
   157       /// Map's value type. (The type of objects associated with the keys).
   157       /// The value type of the map. (The type of objects associated with the keys).
   158       typedef T Value;
   158       typedef T Value;
   159       /// Map's reference type.
   159       /// The reference type of the map.
   160       typedef R Reference;
   160       typedef R Reference;
   161       /// Map's const reference type.
   161       /// The const reference type of the map.
   162       typedef CR ConstReference;
   162       typedef CR ConstReference;
   163 
   163 
   164     protected:
   164     protected:
   165       Value tmp;
   165       Value tmp;
   166     public:
   166     public: