lemon/concepts/maps.h
changeset 92 5d4decd1b870
parent 51 90201bb15a8d
child 79 d73c2e8b25cb
equal deleted inserted replaced
5:0ad4181e9b28 6:f7e467d44b8e
    53       ///
    53       ///
    54       Value operator[](const Key &) const {return Value();}
    54       Value operator[](const Key &) const {return Value();}
    55 
    55 
    56       template<typename _ReadMap>
    56       template<typename _ReadMap>
    57       struct Constraints {
    57       struct Constraints {
    58 
       
    59 	void constraints() {
    58 	void constraints() {
    60 	  Value val = m[key];
    59 	  Value val = m[key];
    61 	  val = m[key];
    60 	  val = m[key];
    62 	  typename _ReadMap::Value own_val = m[own_key]; 
    61 	  typename _ReadMap::Value own_val = m[own_key]; 
    63 	  own_val = m[own_key]; 
    62 	  own_val = m[own_key]; 
   173       ConstReference operator[](const Key &) const { return tmp; }
   172       ConstReference operator[](const Key &) const { return tmp; }
   174       /// Sets the value associated with a key.
   173       /// Sets the value associated with a key.
   175       void set(const Key &k,const Value &t) { operator[](k)=t; }
   174       void set(const Key &k,const Value &t) { operator[](k)=t; }
   176 
   175 
   177       template<typename _ReferenceMap>
   176       template<typename _ReferenceMap>
   178       struct ReferenceMapConcept {
   177       struct Constraints {
   179 
   178 	void constraints() {
   180 	void constraints() {
   179 	  checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
   181 	  checkConcept<ReadWriteMap, _ReferenceMap >();
       
   182 	  m[key] = val;
   180 	  m[key] = val;
   183 	  val  = m[key];
   181 	  val  = m[key];
   184 	  m[key] = ref;
   182 	  m[key] = ref;
   185 	  ref = m[key];
   183 	  ref = m[key];
   186 	  m[own_key] = own_val;
   184 	  m[own_key] = own_val;
   189 	  own_ref = m[own_key];	  	  
   187 	  own_ref = m[own_key];	  	  
   190 	}
   188 	}
   191 
   189 
   192 	typename _ReferenceMap::Key& own_key;
   190 	typename _ReferenceMap::Key& own_key;
   193 	typename _ReferenceMap::Value& own_val;
   191 	typename _ReferenceMap::Value& own_val;
   194 	typename _ReferenceMap::Reference& own_ref;
   192 	typename _ReferenceMap::Reference own_ref;
   195 	Key& key;
   193 	Key& key;
   196 	Value& val;
   194 	Value& val;
   197 	Reference& ref;
   195 	Reference ref;
   198 	_ReferenceMap& m;
   196 	_ReferenceMap& m;
   199       };
   197       };
   200     };
   198     };
   201 
   199 
   202     // @}
   200     // @}