Changeset 2564:3250756f5add in lemon-0.x for lemon/concepts/maps.h
- Timestamp:
- 02/05/08 13:41:05 (16 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3445
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concepts/maps.h
r2553 r2564 35 35 36 36 /// Readable map concept 37 38 /// Readable map concept. 39 /// 37 40 template<typename K, typename T> 38 41 class ReadMap 39 42 { 40 43 public: 41 /// Map's key type. 42 typedef K Key; 43 /// Map's value type. (The type of objects associated with the keys). 44 typedef T Value; 45 46 // \bug Value don't need to be default constructible. 44 /// The key type of the map. 45 typedef K Key; 46 /// The value type of the map. (The type of objects associated with the keys). 47 typedef T Value; 48 47 49 /// Returns the value associated with a key. 50 51 /// Returns the value associated with a key. 52 /// \bug Value shouldn't need to be default constructible. 53 /// 48 54 Value operator[](const Key &) const {return Value();} 49 55 … … 70 76 71 77 /// Writable map concept 78 79 /// Writable map concept. 80 /// 72 81 template<typename K, typename T> 73 82 class WriteMap 74 83 { 75 84 public: 76 /// Map's key type.77 typedef K Key; 78 /// Map's value type. (The type of objects associated with the keys).85 /// The key type of the map. 86 typedef K Key; 87 /// The value type of the map. (The type of objects associated with the keys). 79 88 typedef T Value; 80 89 … … 106 115 }; 107 116 108 ///Read/Writable map concept 117 /// Read/writable map concept 118 119 /// Read/writable map concept. 120 /// 109 121 template<typename K, typename T> 110 122 class ReadWriteMap : public ReadMap<K,T>, 111 112 { 113 public: 114 /// Map's key type.115 typedef K Key; 116 /// Map's value type. (The type of objects associated with the keys).123 public WriteMap<K,T> 124 { 125 public: 126 /// The key type of the map. 127 typedef K Key; 128 /// The value type of the map. (The type of objects associated with the keys). 117 129 typedef T Value; 118 130 … … 133 145 134 146 ///Dereferable map concept 147 148 /// Dereferable map concept. 149 /// 150 /// \todo Rethink this concept. 135 151 template<typename K, typename T, typename R, typename CR> 136 152 class ReferenceMap : public ReadWriteMap<K,T> … … 139 155 /// Tag for reference maps. 140 156 typedef True ReferenceMapTag; 141 /// Map's key type.142 typedef K Key; 143 /// Map's value type. (The type of objects associated with the keys).144 typedef T Value; 145 /// Map's reference type.157 /// The key type of the map. 158 typedef K Key; 159 /// The value type of the map. (The type of objects associated with the keys). 160 typedef T Value; 161 /// The reference type of the map. 146 162 typedef R Reference; 147 /// Map's const reference type.163 /// The const reference type of the map. 148 164 typedef CR ConstReference; 149 165 … … 152 168 public: 153 169 154 ///Returns a reference to the value associated toa key.170 ///Returns a reference to the value associated with a key. 155 171 Reference operator[](const Key &) { return tmp; } 156 ///Returns a const reference to the value associated to a key. 157 ConstReference operator[](const Key &) const 158 { return tmp; } 172 ///Returns a const reference to the value associated with a key. 173 ConstReference operator[](const Key &) const { return tmp; } 159 174 /// Sets the value associated with a key. 160 175 void set(const Key &k,const Value &t) { operator[](k)=t; } 161 176 162 // \todo rethink this concept163 177 template<typename _ReferenceMap> 164 struct ReferenceMapConcept{165 166 void constraints() { 167 checkConcept<ReadWriteMap , _ReferenceMap >();178 struct Constraints { 179 180 void constraints() { 181 checkConcept<ReadWriteMap<K, T>, _ReferenceMap >(); 168 182 m[key] = val; 169 183 val = m[key]; … … 178 192 typename _ReferenceMap::Key& own_key; 179 193 typename _ReferenceMap::Value& own_val; 180 typename _ReferenceMap::Reference &own_ref;194 typename _ReferenceMap::Reference own_ref; 181 195 Key& key; 182 196 Value& val; 183 Reference &ref;197 Reference ref; 184 198 _ReferenceMap& m; 185 199 }; … … 189 203 190 204 } //namespace concepts 205 191 206 } //namespace lemon 207 192 208 #endif // LEMON_CONCEPT_MAPS_H
Note: See TracChangeset
for help on using the changeset viewer.