KeySet and ValueSet are inserted into the map structures.
They makes possible the iterating on the keys or values only.
1.1 --- a/src/hugo/Makefile.am Thu Sep 09 09:40:45 2004 +0000
1.2 +++ b/src/hugo/Makefile.am Sun Sep 12 19:32:21 2004 +0000
1.3 @@ -23,7 +23,6 @@
1.4 minlengthpaths.h \
1.5 smart_graph.h \
1.6 sym_map.h \
1.7 - sym_map_factory.h \
1.8 time_measure.h \
1.9 unionfind.h \
1.10 vector_map.h \
2.1 --- a/src/hugo/array_map.h Thu Sep 09 09:40:45 2004 +0000
2.2 +++ b/src/hugo/array_map.h Sun Sep 12 19:32:21 2004 +0000
2.3 @@ -251,6 +251,30 @@
2.4 return ConstIterator(*this, INVALID);
2.5 }
2.6
2.7 + /// The KeySet of the Map.
2.8 + typedef MapConstKeySet<ArrayMap> ConstKeySet;
2.9 +
2.10 + /// KeySet getter function.
2.11 + ConstKeySet keySet() const {
2.12 + return ConstKeySet(*this);
2.13 + }
2.14 +
2.15 + /// The ConstValueSet of the Map.
2.16 + typedef MapConstValueSet<ArrayMap> ConstValueSet;
2.17 +
2.18 + /// ConstValueSet getter function.
2.19 + ConstValueSet valueSet() const {
2.20 + return ConstValueSet(*this);
2.21 + }
2.22 +
2.23 + /// The ValueSet of the Map.
2.24 + typedef MapValueSet<ArrayMap> ValueSet;
2.25 +
2.26 + /// ValueSet getter function.
2.27 + ValueSet valueSet() {
2.28 + return ValueSet(*this);
2.29 + }
2.30 +
2.31 private:
2.32
2.33 void allocate_memory() {
3.1 --- a/src/hugo/map_iterator.h Thu Sep 09 09:40:45 2004 +0000
3.2 +++ b/src/hugo/map_iterator.h Sun Sep 12 19:32:21 2004 +0000
3.3 @@ -4,21 +4,79 @@
3.4
3.5 #include <hugo/extended_pair.h>
3.6
3.7 +///\ingroup graphmaps
3.8 +///\file
3.9 +///\brief Iterators on the maps.
3.10 +
3.11 namespace hugo {
3.12
3.13 + /// \addtogroup graphmaps
3.14 + /// @{
3.15 +
3.16 + /** The base class all of the map iterators.
3.17 + * The class defines the typedefs of the iterators,
3.18 + * simple step functions and equality operators.
3.19 + */
3.20
3.21 template <typename Map>
3.22 - class MapIterator;
3.23 + class MapIteratorBase {
3.24
3.25 - template <typename Map>
3.26 - class MapConstIterator;
3.27 + public:
3.28 + /// The key type of the iterator.
3.29 + typedef typename Map::KeyType KeyType;
3.30 + /// The iterator to iterate on the keys.
3.31 + typedef typename Map::KeyIt KeyIt;
3.32 +
3.33 + /// The value type of the iterator.
3.34 + typedef typename Map::ValueType ValueType;
3.35 + /// The reference type of the iterator.
3.36 + typedef typename Map::ReferenceType ReferenceType;
3.37 + /// The pointer type of the iterator.
3.38 + typedef typename Map::PointerType PointerType;
3.39 +
3.40 + /// The const value type of the iterator.
3.41 + typedef typename Map::ConstValueType ConstValueType;
3.42 + /// The const reference type of the iterator.
3.43 + typedef typename Map::ConstReferenceType ConstReferenceType;
3.44 + /// The pointer type of the iterator.
3.45 + typedef typename Map::ConstPointerType ConstPointerType;
3.46 +
3.47 + protected:
3.48 +
3.49 + KeyIt it;
3.50 +
3.51 + /// Default constructor.
3.52 + MapIteratorBase() {}
3.53 +
3.54 + /// KeyIt initialized MapIteratorBase constructor.
3.55 + MapIteratorBase(const KeyIt pit) : it(pit) {}
3.56 +
3.57 + public:
3.58 +
3.59 + /// Stepping forward in the map.
3.60 + void increment() {
3.61 + ++it;
3.62 + }
3.63 +
3.64 + /// The equality operator of the map.
3.65 + bool operator==(const MapIteratorBase& pit) const {
3.66 + return pit.it == it;
3.67 + }
3.68 +
3.69 + /// The not-equality operator of the map.
3.70 + bool operator!=(const MapIteratorBase& pit) const {
3.71 + return !(*this == pit);
3.72 + }
3.73 + };
3.74 +
3.75 + template <typename Map> class MapConstIterator;
3.76
3.77 /** Compatible iterator with the stl maps' iterators.
3.78 - * It iterates on pairs of a key and a value.
3.79 + * It iterates on pairs of a key and a value.
3.80 */
3.81 template <typename Map>
3.82 - class MapIterator {
3.83 - // friend class Map;
3.84 + class MapIterator : public MapIteratorBase<Map> {
3.85 +
3.86 friend class MapConstIterator<Map>;
3.87
3.88 public:
3.89 @@ -44,27 +102,24 @@
3.90
3.91 public:
3.92
3.93 - /** Constructor to initalize the the iterators returned
3.94 - * by the begin() and end().
3.95 - */
3.96 - MapIterator (Map& pmap, const KeyIt& pit)
3.97 - : map(&pmap), it(pit) {}
3.98 -
3.99 - public:
3.100 -
3.101 - /** Default constructor.
3.102 - */
3.103 - MapIterator() {}
3.104 -
3.105 + /// The reference type of the iterator.
3.106 typedef extended_pair<const KeyType&, const KeyType&,
3.107 ReferenceType, ReferenceType> PairReferenceType;
3.108
3.109 - /** Dereference operator for map.
3.110 - */
3.111 + /// Default constructor.
3.112 + MapIterator() {}
3.113 +
3.114 + /// Constructor to initalize the iterators returned
3.115 + /// by the begin() and end().
3.116 + MapIterator(Map& pmap, const KeyIt& pit)
3.117 + : MapIteratorBase<Map>(pit), map(&pmap) {}
3.118 +
3.119 + /// Dereference operator for the iterator.
3.120 PairReferenceType operator*() {
3.121 return PairReferenceType(it, (*map)[it]);
3.122 }
3.123
3.124 + /// The pointer type of the iterator.
3.125 class PairPointerType {
3.126 friend class MapIterator;
3.127 private:
3.128 @@ -75,64 +130,34 @@
3.129 PairReferenceType* operator->() {return &data;}
3.130 };
3.131
3.132 - /** Arrow operator for map.
3.133 - */
3.134 + /// Arrow operator for the iterator.
3.135 PairPointerType operator->() {
3.136 return PairPointerType(it, ((*map)[it]));
3.137 }
3.138 -
3.139 - /** The pre increment operator of the map.
3.140 - */
3.141 +
3.142 + /// The pre increment operator of the iterator.
3.143 MapIterator& operator++() {
3.144 - ++it;
3.145 + increment();
3.146 return *this;
3.147 }
3.148
3.149 - /** The post increment operator of the map.
3.150 - */
3.151 + /// The post increment operator of the iterator.
3.152 MapIterator operator++(int) {
3.153 MapIterator tmp(it);
3.154 - ++it;
3.155 + increment();
3.156 return tmp;
3.157 }
3.158
3.159 - /** The equality operator of the map.
3.160 - */
3.161 - bool operator==(const MapIterator& p_it) const {
3.162 - return p_it.it == it;
3.163 - }
3.164 -
3.165 - /** The not-equality operator of the map.
3.166 - */
3.167 - bool operator!=(const MapIterator& p_it) const {
3.168 - return !(*this == p_it);
3.169 - }
3.170 -
3.171 - /** The equality operator of the map.
3.172 - */
3.173 - bool operator==(const MapConstIterator<Map>& p_it) const {
3.174 - return p_it.it == it;
3.175 - }
3.176 -
3.177 - /** The not-equality operator of the map.
3.178 - */
3.179 - bool operator!=(const MapConstIterator<Map>& p_it) const {
3.180 - return !(*this == p_it);
3.181 - }
3.182 -
3.183 private:
3.184 Map* map;
3.185 - KeyIt it;
3.186 };
3.187
3.188 /** Compatible iterator with the stl maps' iterators.
3.189 * It iterates on pairs of a key and a value.
3.190 */
3.191 template <typename Map>
3.192 - class MapConstIterator {
3.193 - // friend class Map;
3.194 - friend class MapIterator<Map>;
3.195 -
3.196 + class MapConstIterator : public MapIteratorBase<Map> {
3.197 +
3.198 public:
3.199
3.200 /// The key type of the iterator.
3.201 @@ -156,28 +181,30 @@
3.202
3.203 public:
3.204
3.205 - /** Constructor to initalize the the iterators returned
3.206 - * by the begin() and end().
3.207 - */
3.208 -
3.209 - MapConstIterator (const Map& pmap, const KeyIt& pit)
3.210 - : map(&pmap), it(pit) {}
3.211 -
3.212 - public:
3.213 -
3.214 - /** Default constructor.
3.215 - */
3.216 + /// Default constructor.
3.217 MapConstIterator() {}
3.218
3.219 + /// Constructor to initalize the the iterators returned
3.220 + /// by the begin() and end().
3.221 + MapConstIterator(const Map& pmap, const KeyIt& pit)
3.222 + : MapIteratorBase<Map>(pit), map(&pmap) {}
3.223 +
3.224 + /// Constructor to create const iterator from a non const.
3.225 + MapConstIterator(const MapIterator<Map>& pit) {
3.226 + it = pit.it;
3.227 + map = pit.map;
3.228 + }
3.229 +
3.230 + /// The reference type of map.
3.231 typedef extended_pair<const KeyType&, const KeyType&,
3.232 ConstReferenceType, ConstReferenceType> PairReferenceType;
3.233
3.234 - /** Dereference operator for map.
3.235 - */
3.236 + /// Dereference operator for the iterator.
3.237 PairReferenceType operator*() {
3.238 return PairReferenceType(it, (*map)[it]);
3.239 }
3.240
3.241 + /// The pointer type of the iterator.
3.242 class PairPointerType {
3.243 friend class MapConstIterator;
3.244 private:
3.245 @@ -188,56 +215,322 @@
3.246 PairReferenceType* operator->() {return &data;}
3.247 };
3.248
3.249 - /** Arrow operator for map.
3.250 - */
3.251 + /// Arrow operator for the iterator.
3.252 PairPointerType operator->() {
3.253 return PairPointerType(it, ((*map)[it]));
3.254 }
3.255
3.256 - /** The pre increment operator of the map.
3.257 - */
3.258 + /// The pre increment operator of the iterator.
3.259 MapConstIterator& operator++() {
3.260 - ++it;
3.261 + increment();
3.262 return *this;
3.263 }
3.264
3.265 - /** The post increment operator of the map.
3.266 - */
3.267 + /// The post increment operator of the iterator.
3.268 MapConstIterator operator++(int) {
3.269 MapConstIterator<Map> tmp(it);
3.270 - ++it;
3.271 + increment();
3.272 return tmp;
3.273 }
3.274
3.275 - /** The equality operator of the map.
3.276 - */
3.277 - bool operator==(const MapIterator<Map>& p_it) const {
3.278 - return p_it.it == it;
3.279 - }
3.280 -
3.281 - /** The not-equality operator of the map.
3.282 - */
3.283 - bool operator!=(const MapIterator<Map>& p_it) const {
3.284 - return !(*this == p_it);
3.285 + private:
3.286 + const Map* map;
3.287 + };
3.288 +
3.289 + /** The class makes the KeyIt to an stl compatible iterator
3.290 + * with dereferencing operator.
3.291 + */
3.292 + template <typename Map>
3.293 + class MapKeyIterator : public MapIteratorBase<Map> {
3.294 +
3.295 + public:
3.296 +
3.297 + /// The key type of the iterator.
3.298 + typedef typename Map::KeyType KeyType;
3.299 + /// The iterator to iterate on the keys.
3.300 + typedef typename Map::KeyIt KeyIt;
3.301 +
3.302 + public:
3.303 +
3.304 + /// Default constructor.
3.305 + MapKeyIterator() {}
3.306 +
3.307 + /// KeyIt initialized iterator.
3.308 + MapKeyIterator(const KeyIt& pit) : MapIteratorBase<Map>(pit) {}
3.309 +
3.310 + /// The pre increment operator of the iterator.
3.311 + MapKeyIterator& operator++() {
3.312 + increment();
3.313 + return *this;
3.314 }
3.315
3.316 - /** The equality operator of the map.
3.317 - */
3.318 - bool operator==(const MapConstIterator& p_it) const {
3.319 - return p_it.it == it;
3.320 + /// The post increment operator of the iterator.
3.321 + MapKeyIterator operator++(int) {
3.322 + MapKeyIterator tmp(*this);
3.323 + increment();
3.324 + return tmp;
3.325 }
3.326 -
3.327 - /** The not-equality operator of the map.
3.328 - */
3.329 - bool operator!=(const MapConstIterator& p_it) const {
3.330 - return !(*this == p_it);
3.331 +
3.332 + /// The dereferencing operator of the iterator.
3.333 + KeyType operator*() const {
3.334 + return static_cast<KeyType>(it);
3.335 }
3.336 -
3.337 + };
3.338 +
3.339 + template <typename Map> class MapConstValueIterator;
3.340 +
3.341 + template <typename Map>
3.342 + class MapValueIterator : public MapIteratorBase<Map> {
3.343 +
3.344 + friend class MapConstValueIterator<Map>;
3.345 +
3.346 + public:
3.347 +
3.348 + /// The key type of the iterator.
3.349 + typedef typename Map::KeyType KeyType;
3.350 + /// The iterator to iterate on the keys.
3.351 + typedef typename Map::KeyIt KeyIt;
3.352 +
3.353 +
3.354 + /// The value type of the iterator.
3.355 + typedef typename Map::ValueType ValueType;
3.356 + /// The reference type of the iterator.
3.357 + typedef typename Map::ReferenceType ReferenceType;
3.358 + /// The pointer type of the iterator.
3.359 + typedef typename Map::PointerType PointerType;
3.360 +
3.361 + /// The const value type of the iterator.
3.362 + typedef typename Map::ConstValueType ConstValueType;
3.363 + /// The const reference type of the iterator.
3.364 + typedef typename Map::ConstReferenceType ConstReferenceType;
3.365 + /// The pointer type of the iterator.
3.366 + typedef typename Map::ConstPointerType ConstPointerType;
3.367 +
3.368 private:
3.369 +
3.370 + Map* map;
3.371 +
3.372 + public:
3.373 +
3.374 + /// Default constructor.
3.375 + MapValueIterator() {}
3.376 +
3.377 + /// Map and KeyIt initialized iterator.
3.378 + MapValueIterator(Map& pmap, const KeyIt& pit)
3.379 + : MapIteratorBase<Map>(pit), map(&pmap) {}
3.380 +
3.381 +
3.382 + /// The pre increment operator of the iterator.
3.383 + MapValueIterator& operator++() {
3.384 + increment();
3.385 + return *this;
3.386 + }
3.387 +
3.388 + /// The post increment operator of the iterator.
3.389 + MapValueIterator operator++(int) {
3.390 + MapValueIterator tmp(*this);
3.391 + increment();
3.392 + return tmp;
3.393 + }
3.394 +
3.395 + /// The dereferencing operator of the iterator.
3.396 + ReferenceType operator*() const {
3.397 + return (*map)[it];
3.398 + }
3.399 +
3.400 + /// The arrow operator of the iterator.
3.401 + PointerType operator->() const {
3.402 + return &(operator*());
3.403 + }
3.404 +
3.405 + };
3.406 +
3.407 +
3.408 + template <typename Map>
3.409 + class MapConstValueIterator : public MapIteratorBase<Map> {
3.410 +
3.411 + public:
3.412 +
3.413 + /// The key type of the iterator.
3.414 + typedef typename Map::KeyType KeyType;
3.415 + /// The iterator to iterate on the keys.
3.416 + typedef typename Map::KeyIt KeyIt;
3.417 +
3.418 +
3.419 + /// The value type of the iterator.
3.420 + typedef typename Map::ValueType ValueType;
3.421 + /// The reference type of the iterator.
3.422 + typedef typename Map::ReferenceType ReferenceType;
3.423 + /// The pointer type of the iterator.
3.424 + typedef typename Map::PointerType PointerType;
3.425 +
3.426 + /// The const value type of the iterator.
3.427 + typedef typename Map::ConstValueType ConstValueType;
3.428 + /// The const reference type of the iterator.
3.429 + typedef typename Map::ConstReferenceType ConstReferenceType;
3.430 + /// The pointer type of the iterator.
3.431 + typedef typename Map::ConstPointerType ConstPointerType;
3.432 +
3.433 + private:
3.434 +
3.435 const Map* map;
3.436 - KeyIt it;
3.437 +
3.438 + public:
3.439 +
3.440 + /// Default constructor.
3.441 + MapConstValueIterator() {}
3.442 +
3.443 + /// Constructor to create const iterator from a non const.
3.444 + MapConstValueIterator(const MapValueIterator<Map>& pit) {
3.445 + it = pit.it;
3.446 + map = pit.map;
3.447 + }
3.448 +
3.449 + /// Map and KeyIt initialized iterator.
3.450 + MapConstValueIterator(const Map& pmap, const KeyIt& pit)
3.451 + : MapIteratorBase<Map>(pit), map(&pmap) {}
3.452 +
3.453 + /// The pre increment operator of the iterator.
3.454 + MapConstValueIterator& operator++() {
3.455 + increment();
3.456 + return *this;
3.457 + }
3.458 +
3.459 + /// The post increment operator of the iterator.
3.460 + MapConstValueIterator operator++(int) {
3.461 + MapConstValueIterator tmp(*this);
3.462 + increment();
3.463 + return tmp;
3.464 + }
3.465 +
3.466 + /// The dereferencing operator of the iterator.
3.467 + ConstReferenceType operator*() const {
3.468 + return (*map)[it];
3.469 + }
3.470 +
3.471 + /// The arrow operator of the iterator.
3.472 + ConstPointerType operator->() const {
3.473 + return &(operator*());
3.474 + }
3.475 +
3.476 };
3.477
3.478 +
3.479 + /** This class makes from a map an iteratable set
3.480 + * which contains all the keys of the map.
3.481 + */
3.482 + template <typename Map>
3.483 + class MapConstKeySet {
3.484 +
3.485 + const Map* map;
3.486 +
3.487 + public:
3.488 +
3.489 + /// The key type of the iterator.
3.490 + typedef typename Map::KeyType KeyType;
3.491 + /// The iterator to iterate on the keys.
3.492 + typedef typename Map::KeyIt KeyIt;
3.493 +
3.494 + /// The map initialized const key set.
3.495 + MapConstKeySet(const Map& pmap) : map(&pmap) {}
3.496 +
3.497 + /// The const iterator of the set.
3.498 + typedef MapKeyIterator<Map> ConstIterator;
3.499 +
3.500 + /// It gives back the const iterator pointed to the first element.
3.501 + ConstIterator begin() const {
3.502 + return ConstIterator(KeyIt(*map->getGraph()));
3.503 + }
3.504 +
3.505 + /// It gives back the const iterator pointed to the first ivalid element.
3.506 + ConstIterator end() const {
3.507 + return ConstIterator(KeyIt(INVALID));
3.508 + }
3.509 + };
3.510 +
3.511 + /** This class makes from a map an iteratable set
3.512 + * which contains all the values of the map.
3.513 + * The values cannot be modified.
3.514 + */
3.515 + template <typename Map>
3.516 + class MapConstValueSet {
3.517 +
3.518 + const Map* map;
3.519 +
3.520 + public:
3.521 +
3.522 + /// The key type of the iterator.
3.523 + typedef typename Map::KeyType KeyType;
3.524 + /// The iterator to iterate on the keys.
3.525 + typedef typename Map::KeyIt KeyIt;
3.526 +
3.527 + /// The map initialized const value set.
3.528 + MapConstValueSet(const Map& pmap) : map(&pmap) {}
3.529 +
3.530 + /// The const iterator of the set.
3.531 + typedef MapConstValueIterator<Map> ConstIterator;
3.532 +
3.533 + /// It gives back the const iterator pointed to the first element.
3.534 + ConstIterator begin() const {
3.535 + return ConstIterator(*map, KeyIt(*map->getGraph()));
3.536 + }
3.537 +
3.538 + /// It gives back the const iterator pointed to the first invalid element.
3.539 + ConstIterator end() const {
3.540 + return ConstIterator(*map, KeyIt(INVALID));
3.541 + }
3.542 + };
3.543 +
3.544 +
3.545 + /** This class makes from a map an iteratable set
3.546 + * which contains all the values of the map.
3.547 + * The values can be modified.
3.548 + */
3.549 + template <typename Map>
3.550 + class MapValueSet {
3.551 +
3.552 + Map* map;
3.553 +
3.554 + public:
3.555 +
3.556 + /// The key type of the iterator.
3.557 + typedef typename Map::KeyType KeyType;
3.558 + /// The iterator to iterate on the keys.
3.559 + typedef typename Map::KeyIt KeyIt;
3.560 +
3.561 + /// The map initialized value set.
3.562 + MapValueSet(Map& pmap) : map(&pmap) {}
3.563 +
3.564 + /// The const iterator of the set.
3.565 + typedef MapConstValueIterator<Map> ConstIterator;
3.566 +
3.567 + /// It gives back the const iterator pointed to the first element.
3.568 + ConstIterator begin() const {
3.569 + return ConstIterator(*map, KeyIt(*map->getGraph()));
3.570 + }
3.571 +
3.572 + /// It gives back the const iterator pointed to the first invalid element.
3.573 + ConstIterator end() const {
3.574 + return ConstIterator(*map, KeyIt(INVALID));
3.575 + }
3.576 +
3.577 + /// The iterator of the set.
3.578 + typedef MapValueIterator<Map> Iterator;
3.579 +
3.580 + /// It gives back the iterator pointed to the first element.
3.581 + Iterator begin() {
3.582 + return Iterator(*map, KeyIt(*map->getGraph()));
3.583 + }
3.584 +
3.585 + /// It gives back the iterator pointed to the first invalid element.
3.586 + Iterator end() {
3.587 + return Iterator(*map, KeyIt(INVALID));
3.588 + }
3.589 +
3.590 + };
3.591 +
3.592 + /// @}
3.593 +
3.594 }
3.595
3.596 #endif
4.1 --- a/src/hugo/sym_map_factory.h Thu Sep 09 09:40:45 2004 +0000
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,112 +0,0 @@
4.4 -// -*- c++ -*-
4.5 -#ifndef SYM_MAP_FACTORY_H
4.6 -#define SYM_MAP_FACTORY_H
4.7 -
4.8 -namespace hugo {
4.9 -
4.10 - template <typename Graph, typename Edge, typename EdgeIt>
4.11 - class SymEdgeIt : public EdgeIt {
4.12 - public:
4.13 -
4.14 - SymEdgeIt()
4.15 - : EdgeIt() {}
4.16 -
4.17 - SymEdgeIt(const Graph& graph)
4.18 - : EdgeIt(graph) {
4.19 - while ( n != -1 && (n & 1)) {
4.20 - EdgeIt::operator++();
4.21 - }
4.22 - }
4.23 -
4.24 - SymEdgeIt(Invalid invalid)
4.25 - : EdgeIt(invalid) {}
4.26 -
4.27 - SymEdgeIt(const Graph& graph, Edge edge)
4.28 - : EdgeIt(graph, edge) {}
4.29 -
4.30 - SymEdgeIt& operator++() {
4.31 - EdgeIt::operator++();
4.32 - while ( n != -1 && (n & 1)) {
4.33 - EdgeIt::operator++();
4.34 - }
4.35 - return *this;
4.36 - }
4.37 - };
4.38 -
4.39 - template <typename MapRegistry, template <typename> class MapFactory>
4.40 - class SymMapFactory {
4.41 -
4.42 - public:
4.43 -
4.44 - typedef typename MapRegistry::Graph Graph;
4.45 - typedef typename MapRegistry::KeyType KeyType;
4.46 - typedef typename MapRegistry::KeyIt KeyIt;
4.47 -
4.48 - typedef typename MapRegistry::MapBase MapBase;
4.49 -
4.50 - template <typename V>
4.51 - class Map : public MapFactory<MapRegistry>::template Map<V> {
4.52 -
4.53 - typedef typename MapFactory<MapRegistry>::template Map<V> MapImpl;
4.54 - public:
4.55 -
4.56 - typedef V Value;
4.57 -
4.58 - Map() : MapImpl() {}
4.59 -
4.60 - Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
4.61 -
4.62 - Map(const Graph& g, MapRegistry& r, const Value& v)
4.63 - : MapImpl(g, r, v) {}
4.64 -
4.65 - Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
4.66 -
4.67 - template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
4.68 -
4.69 - Map& operator=(const Map& copy) {
4.70 - MapImpl::operator=(static_cast<const MapImpl&>(copy));
4.71 - return *this;
4.72 - }
4.73 -
4.74 - template <typename CMap> Map& operator=(const CMap& copy) {
4.75 - MapImpl::operator=(copy);
4.76 - return *this;
4.77 - }
4.78 -
4.79 - Value& operator[](const KeyType& key) {
4.80 - int id = MapBase::getGraph()->id(key);
4.81 - return MapImpl::operator[](id >> 1);
4.82 - }
4.83 -
4.84 - const Value& operator[](const KeyType& key) const {
4.85 - int id = MapBase::getGraph()->id(key);
4.86 - return MapImpl::operator[](id >> 1);
4.87 - }
4.88 -
4.89 - const Value& get(const KeyType& key) const {
4.90 - int id = MapBase::getGraph()->id(key);
4.91 - return MapImpl::operator[](id >> 1);
4.92 - }
4.93 -
4.94 - void set(const KeyType& key, const Value& val) {
4.95 - int id = MapBase::getGraph()->id(key);
4.96 - MapImpl::operator[](id >> 1) = val;
4.97 - }
4.98 -
4.99 - void add(const KeyType& key) {
4.100 - int id = MapBase::getGraph()->id(key);
4.101 - if (id & 1) return;
4.102 - MapImpl::add(key);
4.103 - }
4.104 -
4.105 - void erase(const KeyType& key) {
4.106 - int id = MapBase::getGraph()->id(key);
4.107 - if (id & 1) return;
4.108 - MapImpl::add(key);
4.109 - }
4.110 -
4.111 -
4.112 - };
4.113 - };
4.114 -}
4.115 -#endif
5.1 --- a/src/hugo/vector_map.h Thu Sep 09 09:40:45 2004 +0000
5.2 +++ b/src/hugo/vector_map.h Sun Sep 12 19:32:21 2004 +0000
5.3 @@ -202,6 +202,31 @@
5.4 return ConstIterator(*this, INVALID);
5.5 }
5.6
5.7 + /// The KeySet of the Map.
5.8 + typedef MapConstKeySet<VectorMap> ConstKeySet;
5.9 +
5.10 + /// KeySet getter function.
5.11 + ConstKeySet keySet() const {
5.12 + return ConstKeySet(*this);
5.13 + }
5.14 +
5.15 + /// The ConstValueSet of the Map.
5.16 + typedef MapConstValueSet<VectorMap> ConstValueSet;
5.17 +
5.18 + /// ConstValueSet getter function.
5.19 + ConstValueSet valueSet() const {
5.20 + return ConstValueSet(*this);
5.21 + }
5.22 +
5.23 + /// The ValueSet of the Map.
5.24 + typedef MapValueSet<VectorMap> ValueSet;
5.25 +
5.26 + /// ValueSet getter function.
5.27 + ValueSet valueSet() {
5.28 + return ValueSet(*this);
5.29 + }
5.30 +
5.31 +
5.32 private:
5.33
5.34 Container container;