src/lemon/map_iterator.h
changeset 921 818510fa3d99
parent 906 17f31d280385
child 987 87f7c54892df
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/lemon/map_iterator.h	Wed Sep 29 15:30:04 2004 +0000
     1.3 @@ -0,0 +1,692 @@
     1.4 +/* -*- C++ -*-
     1.5 + * src/lemon/map_iterator.h - Part of LEMON, a generic C++ optimization library
     1.6 + *
     1.7 + * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 + * (Egervary Combinatorial Optimization Research Group, EGRES).
     1.9 + *
    1.10 + * Permission to use, modify and distribute this software is granted
    1.11 + * provided that this copyright notice appears in all copies. For
    1.12 + * precise terms see the accompanying LICENSE file.
    1.13 + *
    1.14 + * This software is provided "AS IS" with no warranty of any kind,
    1.15 + * express or implied, and with no claim as to its suitability for any
    1.16 + * purpose.
    1.17 + *
    1.18 + */
    1.19 +
    1.20 +#ifndef LEMON_MAP_ITERATOR_H
    1.21 +#define LEMON_MAP_ITERATOR_H
    1.22 +
    1.23 +#include <iterator>
    1.24 +
    1.25 +#include <lemon/extended_pair.h>
    1.26 +
    1.27 +///\ingroup graphmaps
    1.28 +///\file
    1.29 +///\brief Iterators on the maps.
    1.30 +
    1.31 +namespace lemon {
    1.32 +
    1.33 +  /// \addtogroup graphmaps
    1.34 +  /// @{
    1.35 +
    1.36 +  /** The base class all of the map iterators.
    1.37 +   *  The class defines the typedefs of the iterators,
    1.38 +   *  simple step functions and equality operators.
    1.39 +   */ 
    1.40 +
    1.41 +  template <typename Map>
    1.42 +  class MapIteratorBase {
    1.43 +
    1.44 +  public:
    1.45 +
    1.46 +    /// The key type of the iterator.
    1.47 +    typedef typename Map::KeyType KeyType;
    1.48 +    /// The iterator to iterate on the keys.
    1.49 +    typedef typename Map::KeyIt KeyIt;
    1.50 +
    1.51 +    /// The value type of the iterator.
    1.52 +    typedef typename Map::ValueType ValueType;
    1.53 +    /// The reference type of the iterator.
    1.54 +    typedef typename Map::ReferenceType ReferenceType;
    1.55 +    /// The pointer type of the iterator.
    1.56 +    typedef typename Map::PointerType PointerType;
    1.57 +
    1.58 +    /// The const value type of the iterator.
    1.59 +    typedef typename Map::ConstValueType ConstValueType;
    1.60 +    /// The const reference type of the iterator.
    1.61 +    typedef typename Map::ConstReferenceType ConstReferenceType;
    1.62 +    /// The pointer type of the iterator.
    1.63 +    typedef typename Map::ConstPointerType ConstPointerType;
    1.64 +
    1.65 +  protected:
    1.66 +
    1.67 +    KeyIt it;
    1.68 +
    1.69 +    /// Default constructor.
    1.70 +    MapIteratorBase() {}
    1.71 +
    1.72 +    /// KeyIt initialized MapIteratorBase constructor.
    1.73 +    MapIteratorBase(const KeyIt pit) : it(pit) {}
    1.74 +
    1.75 +  public:
    1.76 +
    1.77 +    /// Stepping forward in the map.   
    1.78 +    void increment() { 
    1.79 +      ++it; 
    1.80 +    }
    1.81 +
    1.82 +    /// The equality operator of the map.
    1.83 +    bool operator==(const MapIteratorBase& pit) const {
    1.84 +      return pit.it == it;
    1.85 +    }
    1.86 +	
    1.87 +    /// The not-equality operator of the map.
    1.88 +    bool operator!=(const MapIteratorBase& pit) const {
    1.89 +      return !(*this == pit);
    1.90 +    }
    1.91 +  };
    1.92 +
    1.93 +  template <typename Map> class MapConstIterator;
    1.94 +
    1.95 +  /** Compatible iterator with the stl maps' iterators.
    1.96 +   * It iterates on pairs of a key and a value.
    1.97 +   */
    1.98 +  template <typename Map>  
    1.99 +  class MapIterator : public MapIteratorBase<Map> {
   1.100 +
   1.101 +    friend class MapConstIterator<Map>;
   1.102 +
   1.103 +
   1.104 +  public:
   1.105 +
   1.106 +    /// The iterator base class.
   1.107 +    typedef MapIteratorBase<Map> Base;
   1.108 +
   1.109 +    /// The key type of the iterator.
   1.110 +    typedef typename Map::KeyType KeyType;
   1.111 +    /// The iterator to iterate on the keys.
   1.112 +    typedef typename Map::KeyIt KeyIt;
   1.113 +
   1.114 +    /// The value type of the iterator.
   1.115 +    typedef typename Map::ValueType ValueType;
   1.116 +    /// The reference type of the iterator.
   1.117 +    typedef typename Map::ReferenceType ReferenceType;
   1.118 +    /// The pointer type of the iterator.
   1.119 +    typedef typename Map::PointerType PointerType;
   1.120 +
   1.121 +    /// The const value type of the iterator.
   1.122 +    typedef typename Map::ConstValueType ConstValueType;
   1.123 +    /// The const reference type of the iterator.
   1.124 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.125 +    /// The pointer type of the iterator.
   1.126 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.127 +    
   1.128 +  public:
   1.129 +
   1.130 +    /// The value type of the iterator.
   1.131 +    typedef extended_pair<KeyType, const KeyType&,
   1.132 +      ValueType, const ValueType&> PairValueType;
   1.133 +
   1.134 +    /// The reference type of the iterator. 
   1.135 +    typedef extended_pair<const KeyType&, const KeyType&, 
   1.136 +      ReferenceType, ReferenceType> PairReferenceType;
   1.137 +
   1.138 +    /// Default constructor. 
   1.139 +    MapIterator() {}
   1.140 +
   1.141 +    /// Constructor to initalize the iterators returned 
   1.142 +    /// by the begin() and end().
   1.143 +    MapIterator(Map& pmap, const KeyIt& pit) : Base(pit), map(&pmap) {}
   1.144 +
   1.145 +    /// Dereference operator for the iterator.
   1.146 +    PairReferenceType operator*() {
   1.147 +      return PairReferenceType(Base::it, (*map)[Base::it]);
   1.148 +    }
   1.149 +
   1.150 +    /// The pointer type of the iterator.
   1.151 +    class PairPointerType {
   1.152 +      friend class MapIterator;
   1.153 +    private:
   1.154 +      PairReferenceType data;
   1.155 +      PairPointerType(const KeyType& key, ReferenceType val) 
   1.156 +	: data(key, val) {}
   1.157 +    public:
   1.158 +      PairReferenceType* operator->() {return &data;}
   1.159 +    };
   1.160 +
   1.161 +    /// Arrow operator for the iterator.
   1.162 +    PairPointerType operator->() {
   1.163 +      return PairPointerType(Base::it, ((*map)[Base::it])); 
   1.164 +    }
   1.165 +	
   1.166 +    /// The pre increment operator of the iterator.
   1.167 +    MapIterator& operator++() { 
   1.168 +      Base::increment(); 
   1.169 +      return *this; 
   1.170 +    }
   1.171 +
   1.172 +    /// The post increment operator of the iterator.
   1.173 +    MapIterator operator++(int) { 
   1.174 +      MapIterator tmp(*this); 
   1.175 +      Base::increment(); 
   1.176 +      return tmp; 
   1.177 +    }
   1.178 +
   1.179 +  private:
   1.180 +    Map* map;
   1.181 +
   1.182 +  public:
   1.183 +    // STL  compatibility typedefs.
   1.184 +    typedef std::forward_iterator_tag iterator_category;
   1.185 +    typedef int difference_type;
   1.186 +    typedef PairValueType value_type;
   1.187 +    typedef PairReferenceType reference;
   1.188 +    typedef PairPointerType pointer;
   1.189 +  };
   1.190 +
   1.191 +  /** Compatible iterator with the stl maps' iterators.
   1.192 +   *  It iterates on pairs of a key and a value.
   1.193 +   */
   1.194 +  template <typename Map>
   1.195 +  class MapConstIterator : public MapIteratorBase<Map> {
   1.196 +    
   1.197 +  public:
   1.198 +
   1.199 +    /// The iterator base class.
   1.200 +    typedef MapIteratorBase<Map> Base;
   1.201 +
   1.202 +    /// The key type of the iterator.
   1.203 +    typedef typename Map::KeyType KeyType;
   1.204 +    /// The iterator to iterate on the keys.
   1.205 +    typedef typename Map::KeyIt KeyIt;
   1.206 +
   1.207 +    /// The value type of the iterator.
   1.208 +    typedef typename Map::ValueType ValueType;
   1.209 +    /// The reference type of the iterator.
   1.210 +    typedef typename Map::ReferenceType ReferenceType;
   1.211 +    /// The pointer type of the iterator.
   1.212 +    typedef typename Map::PointerType PointerType;
   1.213 +
   1.214 +    /// The const value type of the iterator.
   1.215 +    typedef typename Map::ConstValueType ConstValueType;
   1.216 +    /// The const reference type of the iterator.
   1.217 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.218 +    /// The pointer type of the iterator.
   1.219 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.220 +
   1.221 +  public:    
   1.222 +
   1.223 +    /// Default constructor. 
   1.224 +    MapConstIterator() {}
   1.225 +
   1.226 +    /// Constructor to initalize the the iterators returned
   1.227 +    ///  by the begin() and end().
   1.228 +    MapConstIterator(const Map& pmap, const KeyIt& pit) 
   1.229 +      : Base(pit), map(&pmap) {}
   1.230 +
   1.231 +    /// Constructor to create const iterator from a non const.
   1.232 +    MapConstIterator(const MapIterator<Map>& pit) {
   1.233 +      Base::it = pit.Base::it;
   1.234 +      map = pit.map;
   1.235 +    }
   1.236 +
   1.237 +    /// The value type of the iterator.
   1.238 +    typedef extended_pair<KeyType, const KeyType&,
   1.239 +      ValueType, const ValueType&> PairValueType;
   1.240 +
   1.241 +    /// The reference type of map.
   1.242 +    typedef extended_pair<const KeyType&, const KeyType&, 
   1.243 +      ConstReferenceType, ConstReferenceType> PairReferenceType;
   1.244 +
   1.245 +    /// Dereference operator for the iterator.
   1.246 +    PairReferenceType operator*() {
   1.247 +      return PairReferenceType(Base::it, (*map)[Base::it]);
   1.248 +    }
   1.249 +
   1.250 +    /// The pointer type of the iterator.
   1.251 +    class PairPointerType {
   1.252 +      friend class MapConstIterator;
   1.253 +    private:
   1.254 +      PairReferenceType data;
   1.255 +      PairPointerType(const KeyType& key, ConstReferenceType val) 
   1.256 +	: data(key, val) {}
   1.257 +    public:
   1.258 +      PairReferenceType* operator->() {return &data;}
   1.259 +    };
   1.260 +
   1.261 +    /// Arrow operator for the iterator.
   1.262 +    PairPointerType operator->() {
   1.263 +      return PairPointerType(Base::it, (*map)[Base::it]); 
   1.264 +    }
   1.265 +
   1.266 +    /// The pre increment operator of the iterator.
   1.267 +    MapConstIterator& operator++() { 
   1.268 +      Base::increment(); 
   1.269 +      return *this; 
   1.270 +    }
   1.271 +
   1.272 +    /// The post increment operator of the iterator.
   1.273 +    MapConstIterator operator++(int) { 
   1.274 +      MapConstIterator tmp(*this); 
   1.275 +      Base::increment(); 
   1.276 +      return tmp; 
   1.277 +    }
   1.278 +
   1.279 +  private:
   1.280 +    const Map* map;
   1.281 +
   1.282 +  public:
   1.283 +    // STL  compatibility typedefs.
   1.284 +    typedef std::input_iterator_tag iterator_category;
   1.285 +    typedef int difference_type;
   1.286 +    typedef PairValueType value_type;
   1.287 +    typedef PairReferenceType reference;
   1.288 +    typedef PairPointerType pointer;
   1.289 +  };
   1.290 +
   1.291 +  /** The class makes the KeyIt to an stl compatible iterator
   1.292 +   *  with dereferencing operator.
   1.293 +   */
   1.294 +  template <typename Map>
   1.295 +  class MapKeyIterator : public MapIteratorBase<Map> {
   1.296 +
   1.297 +  public:
   1.298 +
   1.299 +    /// The iterator base class.
   1.300 +    typedef MapIteratorBase<Map> Base;
   1.301 + 
   1.302 +    /// The key type of the iterator.
   1.303 +    typedef typename Map::KeyType KeyType;
   1.304 +    /// The iterator to iterate on the keys.
   1.305 +    typedef typename Map::KeyIt KeyIt;
   1.306 +
   1.307 +  public:
   1.308 +
   1.309 +    /// Default constructor.
   1.310 +    MapKeyIterator() {}
   1.311 +
   1.312 +    /// KeyIt initialized iterator.
   1.313 +    MapKeyIterator(const KeyIt& pit) : Base(pit) {}
   1.314 +
   1.315 +    /// The pre increment operator of the iterator.
   1.316 +    MapKeyIterator& operator++() {
   1.317 +      Base::increment(); 
   1.318 +      return *this; 
   1.319 +    }
   1.320 +
   1.321 +    /// The post increment operator of the iterator.
   1.322 +    MapKeyIterator operator++(int) {
   1.323 +      MapKeyIterator tmp(*this);
   1.324 +      Base::increment();
   1.325 +      return tmp;
   1.326 +    }
   1.327 +
   1.328 +    /// The dereferencing operator of the iterator.
   1.329 +    KeyType operator*() const {
   1.330 +      return static_cast<KeyType>(Base::it);
   1.331 +    }
   1.332 +
   1.333 +  public:
   1.334 +    // STL  compatibility typedefs.
   1.335 +    typedef std::input_iterator_tag iterator_category;
   1.336 +    typedef int difference_type;
   1.337 +    typedef KeyType value_type;
   1.338 +    typedef const KeyType& reference;
   1.339 +    typedef const KeyType* pointer;
   1.340 +  };
   1.341 +
   1.342 +  template <typename Map> class MapConstValueIterator;
   1.343 +
   1.344 +  /** MapValueIterator creates an stl compatible iterator
   1.345 +   *  for the values.
   1.346 +   */
   1.347 +  template <typename Map>
   1.348 +  class MapValueIterator : public MapIteratorBase<Map> {
   1.349 +
   1.350 +    friend class MapConstValueIterator<Map>;
   1.351 +
   1.352 +  public:
   1.353 +
   1.354 +    /// The iterator base class.
   1.355 +    typedef MapIteratorBase<Map> Base;
   1.356 +
   1.357 +    /// The key type of the iterator.
   1.358 +    typedef typename Map::KeyType KeyType;
   1.359 +    /// The iterator to iterate on the keys.
   1.360 +    typedef typename Map::KeyIt KeyIt;
   1.361 +
   1.362 +
   1.363 +    /// The value type of the iterator.
   1.364 +    typedef typename Map::ValueType ValueType;
   1.365 +    /// The reference type of the iterator.
   1.366 +    typedef typename Map::ReferenceType ReferenceType;
   1.367 +    /// The pointer type of the iterator.
   1.368 +    typedef typename Map::PointerType PointerType;
   1.369 +
   1.370 +    /// The const value type of the iterator.
   1.371 +    typedef typename Map::ConstValueType ConstValueType;
   1.372 +    /// The const reference type of the iterator.
   1.373 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.374 +    /// The pointer type of the iterator.
   1.375 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.376 +
   1.377 +  private:
   1.378 +
   1.379 +    Map* map;
   1.380 +
   1.381 +  public:
   1.382 +
   1.383 +    /// Default constructor.
   1.384 +    MapValueIterator() {}
   1.385 +
   1.386 +    /// Map and KeyIt initialized iterator.
   1.387 +    MapValueIterator(Map& pmap, const KeyIt& pit) 
   1.388 +      : Base(pit), map(&pmap) {}
   1.389 +    
   1.390 +
   1.391 +    /// The pre increment operator of the iterator.
   1.392 +    MapValueIterator& operator++() {
   1.393 +      Base::increment(); 
   1.394 +      return *this; 
   1.395 +    }
   1.396 +
   1.397 +    /// The post increment operator of the iterator.
   1.398 +    MapValueIterator operator++(int) {
   1.399 +      MapValueIterator tmp(*this);
   1.400 +      Base::increment();
   1.401 +      return tmp;
   1.402 +    }
   1.403 +
   1.404 +    /// The dereferencing operator of the iterator.
   1.405 +    ReferenceType operator*() const {
   1.406 +      return (*map)[Base::it];
   1.407 +    }
   1.408 +
   1.409 +    /// The arrow operator of the iterator.
   1.410 +    PointerType operator->() const {
   1.411 +      return &(operator*());
   1.412 +    }
   1.413 +
   1.414 +  public:
   1.415 +    // STL  compatibility typedefs.
   1.416 +    typedef std::forward_iterator_tag iterator_category;
   1.417 +    typedef int difference_type;
   1.418 +    typedef ValueType value_type;
   1.419 +    typedef ReferenceType reference;
   1.420 +    typedef PointerType pointer;
   1.421 +  };
   1.422 +
   1.423 +  /** MapValueIterator creates an stl compatible iterator
   1.424 +   *  for the const values.
   1.425 +   */
   1.426 +
   1.427 +  template <typename Map>
   1.428 +  class MapConstValueIterator : public MapIteratorBase<Map> {
   1.429 +
   1.430 +  public:
   1.431 +
   1.432 +    /// The iterator base class.
   1.433 +    typedef MapIteratorBase<Map> Base;
   1.434 +
   1.435 +    /// The key type of the iterator.
   1.436 +    typedef typename Map::KeyType KeyType;
   1.437 +    /// The iterator to iterate on the keys.
   1.438 +    typedef typename Map::KeyIt KeyIt;
   1.439 +
   1.440 +    /// The value type of the iterator.
   1.441 +    typedef typename Map::ValueType ValueType;
   1.442 +    /// The reference type of the iterator.
   1.443 +    typedef typename Map::ReferenceType ReferenceType;
   1.444 +    /// The pointer type of the iterator.
   1.445 +    typedef typename Map::PointerType PointerType;
   1.446 +
   1.447 +    /// The const value type of the iterator.
   1.448 +    typedef typename Map::ConstValueType ConstValueType;
   1.449 +    /// The const reference type of the iterator.
   1.450 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.451 +    /// The pointer type of the iterator.
   1.452 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.453 +
   1.454 +  private:
   1.455 +
   1.456 +    const Map* map;
   1.457 +
   1.458 +  public:
   1.459 +
   1.460 +    /// Default constructor.
   1.461 +    MapConstValueIterator() {}
   1.462 +
   1.463 +    /// Constructor to create const iterator from a non const.
   1.464 +    MapConstValueIterator(const MapValueIterator<Map>& pit) {
   1.465 +      Base::it = pit.Base::it;
   1.466 +      map = pit.map;
   1.467 +    }
   1.468 +
   1.469 +    /// Map and KeyIt initialized iterator.
   1.470 +    MapConstValueIterator(const Map& pmap, const KeyIt& pit) 
   1.471 +      : Base(pit), map(&pmap) {}
   1.472 +
   1.473 +    /// The pre increment operator of the iterator.
   1.474 +    MapConstValueIterator& operator++() {
   1.475 +      Base::increment(); 
   1.476 +      return *this; 
   1.477 +    }
   1.478 +
   1.479 +    /// The post increment operator of the iterator.
   1.480 +    MapConstValueIterator operator++(int) {
   1.481 +      MapConstValueIterator tmp(*this);
   1.482 +      Base::increment();
   1.483 +      return tmp;
   1.484 +    }
   1.485 +
   1.486 +    /// The dereferencing operator of the iterator.
   1.487 +    ConstReferenceType operator*() const {
   1.488 +      return (*map)[Base::it];
   1.489 +    }
   1.490 +
   1.491 +    /// The arrow operator of the iterator.
   1.492 +    ConstPointerType operator->() const {
   1.493 +      return &(operator*());
   1.494 +    }
   1.495 +
   1.496 +  public:
   1.497 +    // STL  compatibility typedefs.
   1.498 +    typedef std::input_iterator_tag iterator_category;
   1.499 +    typedef int difference_type;
   1.500 +    typedef ValueType value_type;
   1.501 +    typedef ConstReferenceType reference;
   1.502 +    typedef ConstPointerType pointer;
   1.503 +  };
   1.504 +
   1.505 +
   1.506 +  /** This class makes from a map an iteratable set
   1.507 +   *  which contains all the keys of the map.
   1.508 +   */
   1.509 +  template <typename Map>
   1.510 +  class MapConstKeySet {
   1.511 +
   1.512 +    const Map* map;
   1.513 +
   1.514 +  public:
   1.515 +
   1.516 +    /// The key type of the iterator.
   1.517 +    typedef typename Map::KeyType KeyType;
   1.518 +    /// The iterator to iterate on the keys.
   1.519 +    typedef typename Map::KeyIt KeyIt;
   1.520 +
   1.521 +
   1.522 +    /// The value type of the iterator.
   1.523 +    typedef typename Map::ValueType ValueType;
   1.524 +    /// The reference type of the iterator.
   1.525 +    typedef typename Map::ReferenceType ReferenceType;
   1.526 +    /// The pointer type of the iterator.
   1.527 +    typedef typename Map::PointerType PointerType;
   1.528 +
   1.529 +    /// The const value type of the iterator.
   1.530 +    typedef typename Map::ConstValueType ConstValueType;
   1.531 +    /// The const reference type of the iterator.
   1.532 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.533 +    /// The pointer type of the iterator.
   1.534 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.535 +
   1.536 +    /// The map initialized const key set.
   1.537 +    MapConstKeySet(const Map& pmap) : map(&pmap) {}
   1.538 +
   1.539 +    /// The const iterator of the set.
   1.540 +    typedef MapKeyIterator<Map> ConstIterator;
   1.541 +
   1.542 +    /// It gives back the const iterator pointed to the first element.
   1.543 +    ConstIterator begin() const {
   1.544 +      return ConstIterator(KeyIt(*map->getGraph()));
   1.545 +    }
   1.546 +            
   1.547 +    /// It gives back the const iterator pointed to the first ivalid element.
   1.548 +    ConstIterator end() const {
   1.549 +      return ConstIterator(KeyIt(INVALID));
   1.550 +    }
   1.551 + 
   1.552 +  public:
   1.553 +    // STL  compatibility typedefs.
   1.554 +    typedef ValueType value_type;
   1.555 +    typedef ConstIterator const_iterator;
   1.556 +    typedef ConstReferenceType const_reference;
   1.557 +    typedef ConstPointerType const_pointer;
   1.558 +    typedef int difference_type;
   1.559 +  };
   1.560 +
   1.561 +  /** This class makes from a map an iteratable set
   1.562 +   *  which contains all the values of the map.
   1.563 +   *  The values cannot be modified.
   1.564 +   */
   1.565 +  template <typename Map>
   1.566 +  class MapConstValueSet {
   1.567 +
   1.568 +    const Map* map;
   1.569 +
   1.570 +  public:
   1.571 +
   1.572 +    /// The key type of the iterator.
   1.573 +    typedef typename Map::KeyType KeyType;
   1.574 +    /// The iterator to iterate on the keys.
   1.575 +    typedef typename Map::KeyIt KeyIt;
   1.576 +
   1.577 +
   1.578 +    /// The value type of the iterator.
   1.579 +    typedef typename Map::ValueType ValueType;
   1.580 +    /// The reference type of the iterator.
   1.581 +    typedef typename Map::ReferenceType ReferenceType;
   1.582 +    /// The pointer type of the iterator.
   1.583 +    typedef typename Map::PointerType PointerType;
   1.584 +
   1.585 +    /// The const value type of the iterator.
   1.586 +    typedef typename Map::ConstValueType ConstValueType;
   1.587 +    /// The const reference type of the iterator.
   1.588 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.589 +    /// The pointer type of the iterator.
   1.590 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.591 +
   1.592 +    /// The map initialized const value set.
   1.593 +    MapConstValueSet(const Map& pmap) : map(&pmap) {}
   1.594 +
   1.595 +    /// The const iterator of the set.
   1.596 +    typedef MapConstValueIterator<Map> ConstIterator;
   1.597 +
   1.598 +    /// It gives back the const iterator pointed to the first element.
   1.599 +    ConstIterator begin() const {
   1.600 +      return ConstIterator(*map, KeyIt(*map->getGraph()));
   1.601 +    }
   1.602 +
   1.603 +    /// It gives back the const iterator pointed to the first invalid element.
   1.604 +    ConstIterator end() const {
   1.605 +      return ConstIterator(*map, KeyIt(INVALID));
   1.606 +    }
   1.607 +
   1.608 +  public:
   1.609 +    // STL  compatibility typedefs.
   1.610 +    typedef ValueType value_type;
   1.611 +    typedef ConstIterator const_iterator;
   1.612 +    typedef ConstReferenceType const_reference;
   1.613 +    typedef ConstPointerType const_pointer;
   1.614 +    typedef int difference_type;
   1.615 +  };
   1.616 +
   1.617 +
   1.618 +  /** This class makes from a map an iteratable set
   1.619 +   *  which contains all the values of the map.
   1.620 +   *  The values can be modified.
   1.621 +   */
   1.622 +  template <typename Map>
   1.623 +  class MapValueSet {
   1.624 +
   1.625 +    Map* map;
   1.626 +
   1.627 +  public:
   1.628 +
   1.629 +    /// The key type of the iterator.
   1.630 +    typedef typename Map::KeyType KeyType;
   1.631 +    /// The iterator to iterate on the keys.
   1.632 +    typedef typename Map::KeyIt KeyIt;
   1.633 +
   1.634 +
   1.635 +    /// The value type of the iterator.
   1.636 +    typedef typename Map::ValueType ValueType;
   1.637 +    /// The reference type of the iterator.
   1.638 +    typedef typename Map::ReferenceType ReferenceType;
   1.639 +    /// The pointer type of the iterator.
   1.640 +    typedef typename Map::PointerType PointerType;
   1.641 +
   1.642 +    /// The const value type of the iterator.
   1.643 +    typedef typename Map::ConstValueType ConstValueType;
   1.644 +    /// The const reference type of the iterator.
   1.645 +    typedef typename Map::ConstReferenceType ConstReferenceType;
   1.646 +    /// The pointer type of the iterator.
   1.647 +    typedef typename Map::ConstPointerType ConstPointerType;
   1.648 +
   1.649 +    /// The map initialized value set.
   1.650 +    MapValueSet(Map& pmap) : map(&pmap) {}
   1.651 +
   1.652 +    /// The const iterator of the set.
   1.653 +    typedef MapConstValueIterator<Map> ConstIterator;
   1.654 +
   1.655 +    /// It gives back the const iterator pointed to the first element.
   1.656 +    ConstIterator begin() const {
   1.657 +      return ConstIterator(*map, KeyIt(*map->getGraph()));
   1.658 +    }
   1.659 +
   1.660 +    /// It gives back the const iterator pointed to the first invalid element.
   1.661 +    ConstIterator end() const {
   1.662 +      return ConstIterator(*map, KeyIt(INVALID));
   1.663 +    }
   1.664 +
   1.665 +    /// The iterator of the set.
   1.666 +    typedef MapValueIterator<Map> Iterator;
   1.667 +
   1.668 +    /// It gives back the iterator pointed to the first element.
   1.669 +    Iterator begin() {
   1.670 +      return Iterator(*map, KeyIt(*map->getGraph()));
   1.671 +    }
   1.672 +
   1.673 +    /// It gives back the iterator pointed to the first invalid element.
   1.674 +    Iterator end() {
   1.675 +      return Iterator(*map, KeyIt(INVALID));
   1.676 +    }
   1.677 +            
   1.678 +  public:
   1.679 +    // STL  compatibility typedefs.
   1.680 +    typedef ValueType value_type;
   1.681 +    typedef Iterator iterator;
   1.682 +    typedef ConstIterator const_iterator;
   1.683 +    typedef ReferenceType reference;
   1.684 +    typedef ConstReferenceType const_reference;
   1.685 +    typedef PointerType pointer;
   1.686 +    typedef ConstPointerType const_pointer;
   1.687 +    typedef int difference_type;
   1.688 +
   1.689 +  };
   1.690 +
   1.691 +  /// @}
   1.692 +
   1.693 +}
   1.694 +
   1.695 +#endif