lemon/maps.h
changeset 44 7bbd94715db5
parent 42 3a98515e9bc3
parent 43 17e76967c49f
child 51 90201bb15a8d
equal deleted inserted replaced
7:479e9558ae99 9:93c2f4eb086d
   113     void setAll(const T &t) {
   113     void setAll(const T &t) {
   114       v = t;
   114       v = t;
   115     }    
   115     }    
   116 
   116 
   117     template<typename T1>
   117     template<typename T1>
   118     struct rebind {
       
   119       typedef ConstMap<K, T1> other;
       
   120     };
       
   121 
       
   122     template<typename T1>
       
   123     ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
   118     ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
   124   };
   119   };
   125 
   120 
   126   ///Returns a \c ConstMap class
   121   ///Returns a \c ConstMap class
   127 
   122 
   241     void setAll(const T &t) {
   236     void setAll(const T &t) {
   242       _value = t;
   237       _value = t;
   243       _map.clear();
   238       _map.clear();
   244     }    
   239     }    
   245 
   240 
   246     template <typename T1, typename C1 = std::less<T1> >
       
   247     struct rebind {
       
   248       typedef StdMap<Key, T1, C1> other;
       
   249     };
       
   250   };
   241   };
   251 
   242 
   252   /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
   243   /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
   253   ///
   244   ///
   254   /// The current map has the <tt>[0..size-1]</tt> keyset and the values
   245   /// The current map has the <tt>[0..size-1]</tt> keyset and the values
   390     return ConvertMap<M, T>(m);
   381     return ConvertMap<M, T>(m);
   391   }
   382   }
   392 
   383 
   393   ///Simple wrapping of a map
   384   ///Simple wrapping of a map
   394 
   385 
   395   ///This \c concepts::ReadMap "read only map" returns the simple
   386   ///This \ref concepts::ReadMap "read only map" returns the simple
   396   ///wrapping of the given map. Sometimes the reference maps cannot be
   387   ///wrapping of the given map. Sometimes the reference maps cannot be
   397   ///combined with simple read maps. This map adaptor wraps the given
   388   ///combined with simple read maps. This map adaptor wraps the given
   398   ///map to simple read map.
   389   ///map to simple read map.
   399   ///
   390   ///
   400   ///\sa SimpleWriteMap
   391   ///\sa SimpleWriteMap
   413     SimpleMap(const M &_m) : m(_m) {};
   404     SimpleMap(const M &_m) : m(_m) {};
   414     ///\e
   405     ///\e
   415     Value operator[](Key k) const {return m[k];}
   406     Value operator[](Key k) const {return m[k];}
   416   };
   407   };
   417 
   408 
   418   ///Simple writable wrapping of the map
   409   ///Simple writable wrapping of a map
   419 
   410 
   420   ///This \c concepts::WriteMap "write map" returns the simple
   411   ///This \ref concepts::WriteMap "write map" returns the simple
   421   ///wrapping of the given map. Sometimes the reference maps cannot be
   412   ///wrapping of the given map. Sometimes the reference maps cannot be
   422   ///combined with simple read-write maps. This map adaptor wraps the
   413   ///combined with simple read-write maps. This map adaptor wraps the
   423   ///given map to simple read-write map.
   414   ///given map to simple read-write map.
   424   ///
   415   ///
   425   ///\sa SimpleMap
   416   ///\sa SimpleMap
  1551     /// Number of set operations.
  1542     /// Number of set operations.
  1552     int num() const {
  1543     int num() const {
  1553       return counter;
  1544       return counter;
  1554     }
  1545     }
  1555 
  1546 
  1556     /// Setter function of the map
  1547     /// The \c set function of the map
  1557     void set(const Key& key, Value value) {
  1548     void set(const Key& key, Value value) {
  1558       if (value) {
  1549       if (value) {
  1559 	map.set(key, counter++);
  1550 	map.set(key, counter++);
  1560       }
  1551       }
  1561     }
  1552     }