Minor doc fixes.
Replaced \c by \ref and \ref by \c to work properly and to be uniform.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2007
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_CONCEPT_MAPS_H
20 #define LEMON_CONCEPT_MAPS_H
22 #include <lemon/bits/utility.h>
23 #include <lemon/concept_check.h>
27 ///\brief Map concepts checking classes for testing and documenting.
33 /// \addtogroup concept
36 /// Readable map concept
38 /// Readable map concept.
40 template<typename K, typename T>
44 /// The key type of the map.
46 /// The value type of the map. (The type of objects associated with the keys).
49 /// Returns the value associated with a key.
51 /// \bug Value shouldn't need to be default constructible.
53 Value operator[](const Key &) const {return Value();}
55 template<typename _ReadMap>
61 typename _ReadMap::Value own_val = m[own_key];
64 ignore_unused_variable_warning(val);
65 ignore_unused_variable_warning(own_val);
66 ignore_unused_variable_warning(key);
69 typename _ReadMap::Key& own_key;
76 /// Writable map concept
78 /// Writable map concept.
80 template<typename K, typename T>
84 /// The key type of the map.
86 /// The value type of the map. (The type of objects associated with the keys).
89 /// Sets the value associated with a key.
90 void set(const Key &,const Value &) {}
92 ///Default constructor
95 template <typename _WriteMap>
98 // No constraints for constructor.
100 m.set(own_key, own_val);
101 ignore_unused_variable_warning(key);
102 ignore_unused_variable_warning(val);
103 ignore_unused_variable_warning(own_key);
104 ignore_unused_variable_warning(own_val);
108 typename _WriteMap::Value own_val;
110 typename _WriteMap::Key& own_key;
116 /// Read/Writable map concept
118 /// Read/writable map concept.
120 template<typename K, typename T>
121 class ReadWriteMap : public ReadMap<K,T>,
125 /// The key type of the map.
127 /// The value type of the map. (The type of objects associated with the keys).
130 /// Returns the value associated with a key.
131 Value operator[](const Key &) const {return Value();}
132 /// Sets the value associated with a key.
133 void set(const Key & ,const Value &) {}
135 template<typename _ReadWriteMap>
138 checkConcept<ReadMap<K, T>, _ReadWriteMap >();
139 checkConcept<WriteMap<K, T>, _ReadWriteMap >();
145 /// Dereferable map concept
147 /// Dereferable map concept.
149 template<typename K, typename T, typename R, typename CR>
150 class ReferenceMap : public ReadWriteMap<K,T>
153 /// Tag for reference maps.
154 typedef True ReferenceMapTag;
155 /// The key type of the map.
157 /// The value type of the map. (The type of objects associated with the keys).
159 /// The reference type of the map.
161 /// The const reference type of the map.
162 typedef CR ConstReference;
168 ///Returns a reference to the value associated to a key.
169 Reference operator[](const Key &) { return tmp; }
170 ///Returns a const reference to the value associated to a key.
171 ConstReference operator[](const Key &) const { return tmp; }
172 /// Sets the value associated with a key.
173 void set(const Key &k,const Value &t) { operator[](k)=t; }
175 /// \todo Rethink this concept.
176 template<typename _ReferenceMap>
177 struct ReferenceMapConcept {
180 checkConcept<ReadWriteMap, _ReferenceMap >();
185 m[own_key] = own_val;
186 own_val = m[own_key];
187 m[own_key] = own_ref;
188 own_ref = m[own_key];
191 typename _ReferenceMap::Key& own_key;
192 typename _ReferenceMap::Value& own_val;
193 typename _ReferenceMap::Reference& own_ref;
203 } //namespace concepts
207 #endif // LEMON_CONCEPT_MAPS_H