... | ... |
@@ -31,24 +31,27 @@ |
31 | 31 |
namespace concepts { |
32 | 32 |
|
33 | 33 |
/// \addtogroup concept |
34 | 34 |
/// @{ |
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 | 44 |
/// Map's key type. |
42 | 45 |
typedef K Key; |
43 | 46 |
/// Map's value type. (The type of objects associated with the keys). |
44 | 47 |
typedef T Value; |
45 | 48 |
|
46 | 49 |
/// Returns the value associated with a key. |
47 | 50 |
|
48 |
/// \bug Value |
|
51 |
/// \bug Value shouldn't need to be default constructible. |
|
49 | 52 |
/// |
50 | 53 |
Value operator[](const Key &) const {return Value();} |
51 | 54 |
|
52 | 55 |
template<typename _ReadMap> |
53 | 56 |
struct Constraints { |
54 | 57 |
|
... | ... |
@@ -68,12 +71,15 @@ |
68 | 71 |
}; |
69 | 72 |
|
70 | 73 |
}; |
71 | 74 |
|
72 | 75 |
|
73 | 76 |
/// Writable map concept |
77 |
|
|
78 |
/// Writable map concept. |
|
79 |
/// |
|
74 | 80 |
template<typename K, typename T> |
75 | 81 |
class WriteMap |
76 | 82 |
{ |
77 | 83 |
public: |
78 | 84 |
/// Map's key type. |
79 | 85 |
typedef K Key; |
... | ... |
@@ -104,13 +110,16 @@ |
104 | 110 |
typename _WriteMap::Key& own_key; |
105 | 111 |
_WriteMap& m; |
106 | 112 |
|
107 | 113 |
}; |
108 | 114 |
}; |
109 | 115 |
|
110 |
///Read/Writable map concept |
|
116 |
/// Read/Writable map concept |
|
117 |
|
|
118 |
/// Read/writable map concept. |
|
119 |
/// |
|
111 | 120 |
template<typename K, typename T> |
112 | 121 |
class ReadWriteMap : public ReadMap<K,T>, |
113 | 122 |
public WriteMap<K,T> |
114 | 123 |
{ |
115 | 124 |
public: |
116 | 125 |
/// Map's key type. |
... | ... |
@@ -130,13 +139,16 @@ |
130 | 139 |
checkConcept<WriteMap<K, T>, _ReadWriteMap >(); |
131 | 140 |
} |
132 | 141 |
}; |
133 | 142 |
}; |
134 | 143 |
|
135 | 144 |
|
136 |
///Dereferable map concept |
|
145 |
/// Dereferable map concept |
|
146 |
|
|
147 |
/// Dereferable map concept. |
|
148 |
/// |
|
137 | 149 |
template<typename K, typename T, typename R, typename CR> |
138 | 150 |
class ReferenceMap : public ReadWriteMap<K,T> |
139 | 151 |
{ |
140 | 152 |
public: |
141 | 153 |
/// Tag for reference maps. |
142 | 154 |
typedef True ReferenceMapTag; |
... | ... |
@@ -153,18 +165,17 @@ |
153 | 165 |
Value tmp; |
154 | 166 |
public: |
155 | 167 |
|
156 | 168 |
///Returns a reference to the value associated to a key. |
157 | 169 |
Reference operator[](const Key &) { return tmp; } |
158 | 170 |
///Returns a const reference to the value associated to a key. |
159 |
ConstReference operator[](const Key &) const |
|
160 |
{ return tmp; } |
|
171 |
ConstReference operator[](const Key &) const { return tmp; } |
|
161 | 172 |
/// Sets the value associated with a key. |
162 | 173 |
void set(const Key &k,const Value &t) { operator[](k)=t; } |
163 | 174 |
|
164 |
// \todo |
|
175 |
/// \todo Rethink this concept. |
|
165 | 176 |
template<typename _ReferenceMap> |
166 | 177 |
struct ReferenceMapConcept { |
167 | 178 |
|
168 | 179 |
void constraints() { |
169 | 180 |
checkConcept<ReadWriteMap, _ReferenceMap >(); |
170 | 181 |
m[key] = val; |
... | ... |
@@ -187,8 +198,10 @@ |
187 | 198 |
}; |
188 | 199 |
}; |
189 | 200 |
|
190 | 201 |
// @} |
191 | 202 |
|
192 | 203 |
} //namespace concepts |
204 |
|
|
193 | 205 |
} //namespace lemon |
206 |
|
|
194 | 207 |
#endif // LEMON_CONCEPT_MAPS_H |
0 comments (0 inline)