Port graph_to_eps() and Color from svn -r3482.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
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 The concept of maps.
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 the given key.
50 Value operator[](const Key &) const {
51 return *static_cast<Value *>(0);
54 template<typename _ReadMap>
59 typename _ReadMap::Value own_val = m[own_key];
62 ignore_unused_variable_warning(key);
63 ignore_unused_variable_warning(val);
64 ignore_unused_variable_warning(own_key);
65 ignore_unused_variable_warning(own_val);
68 const typename _ReadMap::Key& own_key;
75 /// Writable map concept
77 /// Writable map concept.
79 template<typename K, typename T>
83 /// The key type of the map.
85 /// The value type of the map. (The type of objects associated with the keys).
88 /// Sets the value associated with the given key.
89 void set(const Key &, const Value &) {}
91 /// Default constructor.
94 template <typename _WriteMap>
98 m.set(own_key, own_val);
100 ignore_unused_variable_warning(key);
101 ignore_unused_variable_warning(val);
102 ignore_unused_variable_warning(own_key);
103 ignore_unused_variable_warning(own_val);
107 const typename _WriteMap::Key& own_key;
108 const typename _WriteMap::Value& own_val;
113 /// Read/writable map concept
115 /// Read/writable map concept.
117 template<typename K, typename T>
118 class ReadWriteMap : public ReadMap<K,T>,
122 /// The key type of the map.
124 /// The value type of the map. (The type of objects associated with the keys).
127 /// Returns the value associated with the given key.
128 Value operator[](const Key &) const {
129 return *static_cast<Value *>(0);
132 /// Sets the value associated with the given 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;
166 /// Returns a reference to the value associated with the given key.
167 Reference operator[](const Key &) {
168 return *static_cast<Value *>(0);
171 /// Returns a const reference to the value associated with the given key.
172 ConstReference operator[](const Key &) const {
173 return *static_cast<Value *>(0);
176 /// Sets the value associated with the given key.
177 void set(const Key &k,const Value &t) { operator[](k)=t; }
179 template<typename _ReferenceMap>
182 checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
187 own_ref = m[own_key];
188 m[own_key] = own_val;
189 m[own_key] = own_ref;
190 m[own_key] = own_cref;
198 const typename _ReferenceMap::Key& own_key;
199 typename _ReferenceMap::Value& own_val;
200 typename _ReferenceMap::Reference own_ref;
201 typename _ReferenceMap::ConstReference own_cref;
208 } //namespace concepts
212 #endif // LEMON_CONCEPT_MAPS_H