lemon/bits/map_iterator.h
changeset 1810 474d093466a5
parent 1809 029cc4f638d1
child 1811 597ce92fae73
     1.1 --- a/lemon/bits/map_iterator.h	Wed Nov 16 14:46:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,854 +0,0 @@
     1.4 -/* -*- C++ -*-
     1.5 - * lemon/map_iterator.h - Part of LEMON, a generic C++ optimization library
     1.6 - *
     1.7 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 - * (Egervary Research Group on Combinatorial Optimization, 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/bits/extended_pair.h>
    1.26 -#include <lemon/graph_utils.h>
    1.27 -
    1.28 -///\ingroup graphmapfactory
    1.29 -///\file
    1.30 -///\brief Iterators on the maps.
    1.31 -
    1.32 -namespace lemon {
    1.33 -
    1.34 -  /// \addtogroup graphmapfactory
    1.35 -  /// @{
    1.36 -
    1.37 -  /** The base class all of the map iterators.
    1.38 -   *  The class defines the typedefs of the iterators,
    1.39 -   *  simple step functions and equality operators.
    1.40 -   */ 
    1.41 -
    1.42 -  template <
    1.43 -    typename _Graph,
    1.44 -    typename _Item>
    1.45 -  class MapIteratorBase {
    1.46 -
    1.47 -  protected:
    1.48 -
    1.49 -    /// The key type of the iterator.
    1.50 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
    1.51 -
    1.52 -    ItemIt it;
    1.53 -
    1.54 -    /// Default constructor.
    1.55 -    MapIteratorBase() {}
    1.56 -
    1.57 -    /// ItemIt initialized MapIteratorBase constructor.
    1.58 -    MapIteratorBase(const ItemIt _it) : it(_it) {}
    1.59 -
    1.60 -  public:
    1.61 -
    1.62 -    /// Stepping forward in the map.   
    1.63 -    void increment() { 
    1.64 -      ++it; 
    1.65 -    }
    1.66 -
    1.67 -    /// The equality operator of the map.
    1.68 -    bool operator==(const MapIteratorBase& _it) const {
    1.69 -      return _it.it == it;
    1.70 -    }
    1.71 -	
    1.72 -    /// The not-equality operator of the map.
    1.73 -    bool operator!=(const MapIteratorBase& _it) const {
    1.74 -      return !(*this == _it);
    1.75 -    }
    1.76 -  };
    1.77 -
    1.78 -
    1.79 -  template <
    1.80 -    typename _Graph,
    1.81 -    typename _Item,
    1.82 -    typename _Map>
    1.83 -  class MapConstIterator;
    1.84 -
    1.85 -  /** Compatible iterator with the stl maps' iterators.
    1.86 -   * It iterates on pairs of a key and a value.
    1.87 -   */
    1.88 -  template <
    1.89 -    typename _Graph,
    1.90 -    typename _Item,
    1.91 -    typename _Map>
    1.92 -  class MapIterator : public MapIteratorBase<_Graph, _Item> {
    1.93 -
    1.94 -    friend class MapConstIterator<_Graph, _Item, _Map>;
    1.95 -
    1.96 -
    1.97 -  public:
    1.98 -
    1.99 -    /// The iterator base class.
   1.100 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   1.101 -
   1.102 -    typedef _Item Item;
   1.103 -    typedef _Map Map;
   1.104 -    typedef _Graph Graph;
   1.105 -
   1.106 -  protected:
   1.107 -
   1.108 -    typedef typename Parent::ItemIt ItemIt;
   1.109 -
   1.110 -    typedef typename _Map::Value MapValue;
   1.111 -    typedef typename _Map::Reference MapReference;
   1.112 -    
   1.113 -  public:
   1.114 -
   1.115 -    /// The value type of the iterator.
   1.116 -    typedef extended_pair<Item, const Item&,
   1.117 -      MapValue, const MapValue&> Value;
   1.118 -
   1.119 -    /// The reference type of the iterator. 
   1.120 -    typedef extended_pair<const Item&, const Item&, 
   1.121 -      MapReference, MapReference> Reference;
   1.122 -
   1.123 -    /// Default constructor. 
   1.124 -    MapIterator() {}
   1.125 -
   1.126 -    /// Constructor to initalize the iterators returned 
   1.127 -    /// by the begin() and end().
   1.128 -    MapIterator(Map& _map, const ItemIt& _it) 
   1.129 -      : Parent(_it), map(&_map) {}
   1.130 -
   1.131 -    /// Dereference operator for the iterator.
   1.132 -    Reference operator*() {
   1.133 -      return Reference(Parent::it, (*map)[Parent::it]);
   1.134 -    }
   1.135 -
   1.136 -    /// The pointer type of the iterator.
   1.137 -    class Pointer {
   1.138 -      friend class MapIterator;
   1.139 -    protected:
   1.140 -      Reference data;
   1.141 -      Pointer(const Item& item, MapReference val) 
   1.142 -	: data(item, val) {}
   1.143 -    public:
   1.144 -      Reference* operator->() {return &data;}
   1.145 -    };
   1.146 -
   1.147 -    /// Arrow operator for the iterator.
   1.148 -    Pointer operator->() {
   1.149 -      return Pointer(Parent::it, (*map)[Parent::it]); 
   1.150 -    }
   1.151 -	
   1.152 -    /// The pre increment operator of the iterator.
   1.153 -    MapIterator& operator++() { 
   1.154 -      Parent::increment(); 
   1.155 -      return *this; 
   1.156 -    }
   1.157 -
   1.158 -    /// The post increment operator of the iterator.
   1.159 -    MapIterator operator++(int) { 
   1.160 -      MapIterator tmp(*this); 
   1.161 -      Parent::increment(); 
   1.162 -      return tmp; 
   1.163 -    }
   1.164 -
   1.165 -  protected:
   1.166 -
   1.167 -    Map* map;
   1.168 -
   1.169 -  public:
   1.170 -    // STL  compatibility typedefs.
   1.171 -    typedef std::forward_iterator_tag iterator_category;
   1.172 -    typedef int difference_type;
   1.173 -    typedef Value value_type;
   1.174 -    typedef Reference reference;
   1.175 -    typedef Pointer pointer;
   1.176 -  };
   1.177 -
   1.178 -  /** Compatible iterator with the stl maps' iterators.
   1.179 -   *  It iterates on pairs of a key and a value.
   1.180 -   */
   1.181 -  template <
   1.182 -    typename _Graph,
   1.183 -    typename _Item,
   1.184 -    typename _Map>
   1.185 -  class MapConstIterator : public MapIteratorBase<_Graph, _Item> {
   1.186 -
   1.187 -  public:
   1.188 -
   1.189 -    /// The iterator base class.
   1.190 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   1.191 -
   1.192 -    typedef _Graph Graph;
   1.193 -    typedef _Item Item;
   1.194 -    typedef _Map Map;
   1.195 -
   1.196 -  protected:
   1.197 -
   1.198 -    typedef typename Parent::ItemIt ItemIt;
   1.199 -
   1.200 -    typedef typename _Map::Value MapValue;
   1.201 -    typedef typename _Map::ConstReference MapReference;
   1.202 -    
   1.203 -  public:
   1.204 -
   1.205 -    /// The value type of the iterator.
   1.206 -    typedef extended_pair<Item, const Item&,
   1.207 -      MapValue, const MapValue&> Value;
   1.208 -
   1.209 -    /// The reference type of the iterator. 
   1.210 -    typedef extended_pair<const Item&, const Item&, 
   1.211 -      MapReference, MapReference> Reference;
   1.212 -
   1.213 -    /// Default constructor. 
   1.214 -    MapConstIterator() {}
   1.215 -
   1.216 -    /// Constructor to initalize the iterators returned 
   1.217 -    /// by the begin() and end().
   1.218 -    MapConstIterator(const Map& _map, const ItemIt& _it) 
   1.219 -      : Parent(_it), map(&_map) {}
   1.220 -
   1.221 -    /// Dereference operator for the iterator.
   1.222 -    Reference operator*() {
   1.223 -      return Reference(Parent::it, (*map)[Parent::it]);
   1.224 -    }
   1.225 -
   1.226 -    /// The pointer type of the iterator.
   1.227 -    class Pointer {
   1.228 -      friend class MapConstIterator;
   1.229 -    protected:
   1.230 -      Reference data;
   1.231 -      Pointer(const Item& item, MapReference val) 
   1.232 -	: data(item, val) {}
   1.233 -    public:
   1.234 -      Reference* operator->() {return &data;}
   1.235 -    };
   1.236 -
   1.237 -    /// Arrow operator for the iterator.
   1.238 -    Pointer operator->() {
   1.239 -      return Pointer(Parent::it, ((*map)[Parent::it])); 
   1.240 -    }
   1.241 -	
   1.242 -    /// The pre increment operator of the iterator.
   1.243 -    MapConstIterator& operator++() { 
   1.244 -      Parent::increment(); 
   1.245 -      return *this; 
   1.246 -    }
   1.247 -
   1.248 -    /// The post increment operator of the iterator.
   1.249 -    MapConstIterator operator++(int) { 
   1.250 -      MapConstIterator tmp(*this); 
   1.251 -      Parent::increment(); 
   1.252 -      return tmp; 
   1.253 -    }
   1.254 -
   1.255 -  protected:
   1.256 -    const Map* map;
   1.257 -
   1.258 -  public:
   1.259 -    // STL  compatibility typedefs.
   1.260 -    typedef std::forward_iterator_tag iterator_category;
   1.261 -    typedef int difference_type;
   1.262 -    typedef Value value_type;
   1.263 -    typedef Reference reference;
   1.264 -    typedef Pointer pointer;
   1.265 -  };
   1.266 - 
   1.267 -  /** The class makes the ItemIt to an stl compatible iterator
   1.268 -   *  with dereferencing operator.
   1.269 -   */
   1.270 -  template <
   1.271 -    typename _Graph,
   1.272 -    typename _Item>
   1.273 -  class MapConstKeyIterator : public MapIteratorBase<_Graph, _Item> {
   1.274 -
   1.275 -  public:
   1.276 -
   1.277 -    /// The iterator base class.
   1.278 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   1.279 - 
   1.280 -    typedef _Graph Graph;
   1.281 -    typedef _Item Item;
   1.282 -
   1.283 -  protected:
   1.284 -    /// The iterator to iterate on the keys.
   1.285 -    typedef typename Parent::ItemIt ItemIt;
   1.286 -
   1.287 -  public:
   1.288 -
   1.289 -    typedef Item Value;
   1.290 -    typedef const Item& Reference;
   1.291 -    typedef const Item* Pointer;
   1.292 -
   1.293 -    /// Default constructor.
   1.294 -    MapConstKeyIterator() {}
   1.295 -
   1.296 -    /// ItemIt initialized iterator.
   1.297 -    MapConstKeyIterator(const ItemIt& pit) : Parent(pit) {}
   1.298 -
   1.299 -    /// The pre increment operator of the iterator.
   1.300 -    MapConstKeyIterator& operator++() {
   1.301 -      Parent::increment(); 
   1.302 -      return *this; 
   1.303 -    }
   1.304 -
   1.305 -    /// The post increment operator of the iterator.
   1.306 -    MapConstKeyIterator operator++(int) {
   1.307 -      MapConstKeyIterator tmp(*this);
   1.308 -      Parent::increment();
   1.309 -      return tmp;
   1.310 -    }
   1.311 -
   1.312 -    /// The dereferencing operator of the iterator.
   1.313 -    Item operator*() const {
   1.314 -      return static_cast<Item>(Parent::it);
   1.315 -    }
   1.316 -
   1.317 -  public:
   1.318 -    // STL  compatibility typedefs.
   1.319 -    typedef std::input_iterator_tag iterator_category;
   1.320 -    typedef int difference_type;
   1.321 -    typedef Value value_type;
   1.322 -    typedef Reference reference;
   1.323 -    typedef Pointer pointer;
   1.324 -  };
   1.325 -
   1.326 -  template <
   1.327 -    typename _Graph, 
   1.328 -    typename _Item,
   1.329 -    typename _Map>
   1.330 -  class MapConstValueIterator;
   1.331 -
   1.332 -  /** MapValueIterator creates an stl compatible iterator
   1.333 -   *  for the values.
   1.334 -   */
   1.335 -  template <
   1.336 -    typename _Graph,
   1.337 -    typename _Item,
   1.338 -    typename _Map>
   1.339 -  class MapValueIterator : public MapIteratorBase<_Graph, _Item> {
   1.340 -
   1.341 -    friend class MapConstValueIterator<_Graph, _Item, _Map>;
   1.342 -
   1.343 -  public:
   1.344 -
   1.345 -    /// The iterator base class.
   1.346 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   1.347 -
   1.348 -    typedef _Graph Graph;
   1.349 -    typedef _Item Item;
   1.350 -    typedef _Map Map;
   1.351 -
   1.352 -  protected:
   1.353 -
   1.354 -    /// The iterator to iterate on the keys.
   1.355 -    typedef typename Parent::ItemIt ItemIt;
   1.356 -
   1.357 -    /// The value type of the iterator.
   1.358 -    typedef typename Map::Value MapValue;
   1.359 -    /// The reference type of the iterator.
   1.360 -    typedef typename Map::Reference MapReference;
   1.361 -    /// The pointer type of the iterator.
   1.362 -    typedef typename Map::Pointer MapPointer;
   1.363 -
   1.364 -  public:
   1.365 -
   1.366 -    typedef MapValue Value;
   1.367 -    typedef MapReference Reference;
   1.368 -    typedef MapPointer Pointer;
   1.369 -
   1.370 -    /// Default constructor.
   1.371 -    MapValueIterator() {}
   1.372 -
   1.373 -    /// Map and ItemIt initialized iterator.
   1.374 -    MapValueIterator(Map& _map, const ItemIt& _it) 
   1.375 -      : Parent(_it), map(&_map) {}
   1.376 -    
   1.377 -
   1.378 -    /// The pre increment operator of the iterator.
   1.379 -    MapValueIterator& operator++() {
   1.380 -      Parent::increment(); 
   1.381 -      return *this; 
   1.382 -    }
   1.383 -
   1.384 -    /// The post increment operator of the iterator.
   1.385 -    MapValueIterator operator++(int) {
   1.386 -      MapValueIterator tmp(*this);
   1.387 -      Parent::increment();
   1.388 -      return tmp;
   1.389 -    }
   1.390 -
   1.391 -    /// The dereferencing operator of the iterator.
   1.392 -    Reference operator*() const {
   1.393 -      return (*map)[Parent::it];
   1.394 -    }
   1.395 -
   1.396 -    /// The arrow operator of the iterator.
   1.397 -    Pointer operator->() const {
   1.398 -      return &(operator*());
   1.399 -    }
   1.400 -
   1.401 -  protected:
   1.402 -
   1.403 -    Map* map;
   1.404 -
   1.405 -  public:
   1.406 -    // STL  compatibility typedefs.
   1.407 -    typedef std::forward_iterator_tag iterator_category;
   1.408 -    typedef int difference_type;
   1.409 -    typedef Value value_type;
   1.410 -    typedef Reference reference;
   1.411 -    typedef Pointer pointer;
   1.412 -  };
   1.413 -
   1.414 -  /** MapValueIterator creates an stl compatible iterator
   1.415 -   *  for the values.
   1.416 -   */
   1.417 -  template <
   1.418 -    typename _Graph,
   1.419 -    typename _Item,
   1.420 -    typename _Map>
   1.421 -  class MapConstValueIterator : public MapIteratorBase<_Graph, _Item> {
   1.422 -
   1.423 -  public:
   1.424 -
   1.425 -    /// The iterator base class.
   1.426 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   1.427 -
   1.428 -    typedef _Graph Graph;
   1.429 -    typedef _Item Item;
   1.430 -    typedef _Map Map;
   1.431 -
   1.432 -  protected:
   1.433 -
   1.434 -    /// The iterator to iterate on the keys.
   1.435 -    typedef typename Parent::ItemIt ItemIt;
   1.436 -
   1.437 -    /// The value type of the iterator.
   1.438 -    typedef typename Map::Value MapValue;
   1.439 -    /// The reference type of the iterator.
   1.440 -    typedef typename Map::ConstReference MapReference;
   1.441 -    /// The pointer type of the iterator.
   1.442 -    typedef typename Map::ConstPointer MapPointer;
   1.443 -
   1.444 -  public:
   1.445 -
   1.446 -    typedef MapValue Value;
   1.447 -    typedef MapReference Reference;
   1.448 -    typedef MapPointer Pointer;
   1.449 -
   1.450 -    /// Default constructor.
   1.451 -    MapConstValueIterator() {}
   1.452 -
   1.453 -    /// Map and ItemIt initialized iterator.
   1.454 -    MapConstValueIterator(const Map& _map, const ItemIt& _it) 
   1.455 -      : Parent(_it), map(&_map) {}
   1.456 -    
   1.457 -
   1.458 -    /// The pre increment operator of the iterator.
   1.459 -    MapConstValueIterator& operator++() {
   1.460 -      Parent::increment(); 
   1.461 -      return *this; 
   1.462 -    }
   1.463 -
   1.464 -    /// The post increment operator of the iterator.
   1.465 -    MapConstValueIterator operator++(int) {
   1.466 -      MapConstValueIterator tmp(*this);
   1.467 -      Parent::increment();
   1.468 -      return tmp;
   1.469 -    }
   1.470 -
   1.471 -    /// The dereferencing operator of the iterator.
   1.472 -    Reference operator*() const {
   1.473 -      return (*map)[Parent::it];
   1.474 -    }
   1.475 -
   1.476 -    /// The arrow operator of the iterator.
   1.477 -    Pointer operator->() const {
   1.478 -      return &(operator*());
   1.479 -    }
   1.480 -
   1.481 -  protected:
   1.482 -
   1.483 -    const Map* map;
   1.484 -
   1.485 -  public:
   1.486 -    // STL  compatibility typedefs.
   1.487 -    typedef std::forward_iterator_tag iterator_category;
   1.488 -    typedef int difference_type;
   1.489 -    typedef Value value_type;
   1.490 -    typedef Reference reference;
   1.491 -    typedef Pointer pointer;
   1.492 -  };
   1.493 -
   1.494 -
   1.495 -  /** This class makes from a map an iteratable set
   1.496 -   *  which contains all the keys of the map.
   1.497 -   */
   1.498 -  template <typename _Graph, typename _Item>
   1.499 -  class MapConstKeySet {
   1.500 -
   1.501 -  public:
   1.502 -
   1.503 -    typedef _Graph Graph;
   1.504 -    /// The key type of the iterator.
   1.505 -    typedef _Item Item;
   1.506 -    /// The iterator to iterate on the keys.
   1.507 -
   1.508 -  protected:
   1.509 -
   1.510 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
   1.511 -
   1.512 -  public:
   1.513 -
   1.514 -    /// The map initialized const key set.
   1.515 -    MapConstKeySet(const Graph& _graph) : graph(&_graph) {}
   1.516 -
   1.517 -    /// The const iterator of the set.
   1.518 -    typedef MapConstKeyIterator<_Graph, _Item> ConstIterator;
   1.519 -
   1.520 -    typedef typename ConstIterator::Value Value;
   1.521 -    /// The reference type of the iterator.
   1.522 -    typedef typename ConstIterator::Reference ConstReference;
   1.523 -    /// The pointer type of the iterator.
   1.524 -    typedef typename ConstIterator::Pointer ConstPointer;
   1.525 -
   1.526 -    /// It gives back the const iterator pointed to the first element.
   1.527 -    ConstIterator begin() const {
   1.528 -      return ConstIterator(ItemIt(*graph));
   1.529 -    }
   1.530 -            
   1.531 -    /// It gives back the const iterator pointed to the first ivalid element.
   1.532 -    ConstIterator end() const {
   1.533 -      return ConstIterator(ItemIt(INVALID));
   1.534 -    }
   1.535 -
   1.536 -  protected:
   1.537 -
   1.538 -    const Graph* graph;
   1.539 - 
   1.540 -  public:
   1.541 -    // STL  compatibility typedefs.
   1.542 -    typedef Value value_type;
   1.543 -    typedef ConstIterator const_iterator;
   1.544 -    typedef ConstReference const_reference;
   1.545 -    typedef ConstPointer const_pointer;
   1.546 -    typedef int difference_type;
   1.547 -  };
   1.548 -
   1.549 -  /** This class makes from a map an iteratable set
   1.550 -   *  which contains all the values of the map.
   1.551 -   *  The values cannot be modified.
   1.552 -   */
   1.553 -  template <typename _Graph, typename _Item, typename _Map>
   1.554 -  class MapConstValueSet {
   1.555 -
   1.556 -  public:
   1.557 -    
   1.558 -    typedef _Graph Graph;
   1.559 -    typedef _Item Item;
   1.560 -    typedef _Map Map;
   1.561 -
   1.562 -  protected:
   1.563 -
   1.564 -    /// The iterator to iterate on the keys.
   1.565 -    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
   1.566 -
   1.567 -  public:
   1.568 -
   1.569 -    /// The map initialized const value set.
   1.570 -    MapConstValueSet(const Graph& _graph, const Map& _map) 
   1.571 -      : graph(&_graph), map(&_map) {}
   1.572 -
   1.573 -    /// The const iterator of the set.
   1.574 -    typedef MapConstValueIterator<_Graph, _Item, _Map> ConstIterator;
   1.575 -
   1.576 -    typedef typename ConstIterator::Value Value;
   1.577 -    typedef typename ConstIterator::Reference ConstReference;
   1.578 -    typedef typename ConstIterator::Pointer ConstPointer;
   1.579 -
   1.580 -    /// It gives back the const iterator pointed to the first element.
   1.581 -    ConstIterator begin() const {
   1.582 -      return ConstIterator(*map, ItemIt(*graph));
   1.583 -    }
   1.584 -
   1.585 -    /// It gives back the const iterator pointed to the first invalid element.
   1.586 -    ConstIterator end() const {
   1.587 -      return ConstIterator(*map, ItemIt(INVALID));
   1.588 -    }
   1.589 -
   1.590 -  protected:
   1.591 -    
   1.592 -    const Map* map;
   1.593 -    const Graph * graph;
   1.594 -
   1.595 -  public:
   1.596 -    // STL  compatibility typedefs.
   1.597 -    typedef Value value_type;
   1.598 -    typedef ConstIterator const_iterator;
   1.599 -    typedef ConstReference const_reference;
   1.600 -    typedef ConstPointer const_pointer;
   1.601 -    typedef int difference_type;
   1.602 -  };
   1.603 -
   1.604 -
   1.605 -  /** This class makes from a map an iteratable set
   1.606 -   *  which contains all the values of the map.
   1.607 -   *  The values can be modified.
   1.608 -   */
   1.609 -  template <typename _Graph, typename _Item, typename _Map>
   1.610 -  class MapValueSet {
   1.611 -
   1.612 -  public:
   1.613 -    
   1.614 -    typedef _Graph Graph;
   1.615 -    typedef _Item Item;
   1.616 -    typedef _Map Map;
   1.617 -
   1.618 -  protected:
   1.619 -
   1.620 -    /// The iterator to iterate on the keys.
   1.621 -    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
   1.622 -
   1.623 -  public:
   1.624 -
   1.625 -    /// The map initialized const value set.
   1.626 -    MapValueSet(const Graph& _graph, Map& _map) 
   1.627 -      : map(&_map), graph(&_graph) {}
   1.628 -
   1.629 -    /// The const iterator of the set.
   1.630 -    typedef MapValueIterator<_Graph, _Item, _Map> Iterator;
   1.631 -    /// The const iterator of the set.
   1.632 -    typedef MapConstValueIterator<_Graph, _Item, _Map> ConstIterator;
   1.633 -
   1.634 -    typedef typename ConstIterator::Value Value;
   1.635 -    typedef typename Iterator::Reference Reference;
   1.636 -    typedef typename Iterator::Pointer Pointer;
   1.637 -    typedef typename ConstIterator::Reference ConstReference;
   1.638 -    typedef typename ConstIterator::Pointer ConstPointer;
   1.639 -
   1.640 -    /// It gives back the const iterator pointed to the first element.
   1.641 -    ConstIterator begin() const {
   1.642 -      return ConstIterator(*map, ItemIt(*graph));
   1.643 -    }
   1.644 -
   1.645 -    /// It gives back the const iterator pointed to the first invalid element.
   1.646 -    ConstIterator end() const {
   1.647 -      return ConstIterator(*map, ItemIt(INVALID));
   1.648 -    }
   1.649 -
   1.650 -    /// It gives back the iterator pointed to the first element.
   1.651 -    Iterator begin() {
   1.652 -      return Iterator(*map, ItemIt(*graph));
   1.653 -    }
   1.654 -
   1.655 -    /// It gives back the iterator pointed to the first invalid element.
   1.656 -    Iterator end() {
   1.657 -      return Iterator(*map, ItemIt(INVALID));
   1.658 -    }
   1.659 -
   1.660 -  protected:
   1.661 -    
   1.662 -    Map* map;
   1.663 -    const Graph * graph;
   1.664 -
   1.665 -  public:
   1.666 -    // STL  compatibility typedefs.
   1.667 -    typedef Value value_type;
   1.668 -    typedef Iterator iterator;
   1.669 -    typedef ConstIterator const_iterator;
   1.670 -    typedef Reference reference;
   1.671 -    typedef ConstReference const_reference;
   1.672 -    typedef Pointer pointer;
   1.673 -    typedef ConstPointer const_pointer;
   1.674 -    typedef int difference_type;
   1.675 -
   1.676 -  };
   1.677 -
   1.678 -  /** This class makes from a map an iteratable set
   1.679 -   *  which contains all the values of the map.
   1.680 -   *  The values can be modified.
   1.681 -   */
   1.682 -  template <
   1.683 -    typename _Graph, 
   1.684 -    typename _Item,
   1.685 -    typename _Map
   1.686 -    >
   1.687 -  class MapSet {
   1.688 -  public:    
   1.689 -
   1.690 -    typedef _Graph Graph;
   1.691 -    typedef _Item Item;
   1.692 -    typedef _Map Map;
   1.693 -
   1.694 -  protected:
   1.695 -
   1.696 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
   1.697 -
   1.698 -  public:
   1.699 -
   1.700 -    /// The map initialized value set.
   1.701 -    MapSet(const Graph& _graph, Map& _map) : graph(&_graph), map(&_map) {}
   1.702 -
   1.703 -    /// The const iterator of the set.
   1.704 -    typedef MapIterator<_Graph, _Item, _Map> Iterator;
   1.705 -    typedef MapConstIterator<_Graph, _Item, _Map> ConstIterator;
   1.706 -
   1.707 -    typedef typename ConstIterator::Value Value;
   1.708 -    typedef typename Iterator::Reference Reference;
   1.709 -    typedef typename Iterator::Pointer Pointer;
   1.710 -    typedef typename ConstIterator::Reference ConstReference;
   1.711 -    typedef typename ConstIterator::Pointer ConstPointer;
   1.712 -
   1.713 -
   1.714 -    /// It gives back the const iterator pointed to the first element.
   1.715 -    ConstIterator begin() const {
   1.716 -      return ConstIterator(*map, ItemIt(*graph));
   1.717 -    }
   1.718 -
   1.719 -    /// It gives back the const iterator pointed to the first invalid element.
   1.720 -    ConstIterator end() const {
   1.721 -      return ConstIterator(*map, ItemIt(INVALID));
   1.722 -    }
   1.723 -
   1.724 -    /// The iterator of the set.
   1.725 -
   1.726 -    /// It gives back the iterator pointed to the first element.
   1.727 -    Iterator begin() {
   1.728 -      return Iterator(*map, ItemIt(*graph));
   1.729 -    }
   1.730 -
   1.731 -    /// It gives back the iterator pointed to the first invalid element.
   1.732 -    Iterator end() {
   1.733 -      return Iterator(*map, ItemIt(INVALID));
   1.734 -    }
   1.735 -
   1.736 -  protected:
   1.737 -    
   1.738 -    const Graph* graph;
   1.739 -    Map* map;
   1.740 -            
   1.741 -  public:
   1.742 -    // STL  compatibility typedefs.
   1.743 -    typedef Value value_type;
   1.744 -    typedef Iterator iterator;
   1.745 -    typedef ConstIterator const_iterator;
   1.746 -    typedef Reference reference;
   1.747 -    typedef ConstReference const_reference;
   1.748 -    typedef Pointer pointer;
   1.749 -    typedef ConstPointer const_pointer;
   1.750 -    typedef int difference_type;
   1.751 -
   1.752 -  };
   1.753 -
   1.754 -  template <
   1.755 -    typename _Graph, 
   1.756 -    typename _Item,
   1.757 -    typename _Map
   1.758 -    >
   1.759 -  class ConstMapSet {
   1.760 -    
   1.761 -    typedef _Graph Graph;
   1.762 -    typedef _Map Map;
   1.763 -
   1.764 -    const Graph* graph;
   1.765 -    const Map* map;
   1.766 -
   1.767 -  public:
   1.768 -
   1.769 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
   1.770 -
   1.771 -
   1.772 -    /// The map initialized value set.
   1.773 -    ConstMapSet(const Graph& _graph, const Map& _map) 
   1.774 -      : graph(&_graph), map(&_map) {}
   1.775 -
   1.776 -    /// The const iterator of the set.
   1.777 -    typedef MapConstIterator<_Graph, _Item, _Map> ConstIterator;
   1.778 -
   1.779 -    typedef typename ConstIterator::Value Value;
   1.780 -    typedef typename ConstIterator::Reference ConstReference;
   1.781 -    typedef typename ConstIterator::Pointer ConstPointer;
   1.782 -
   1.783 -
   1.784 -    /// It gives back the const iterator pointed to the first element.
   1.785 -    ConstIterator begin() const {
   1.786 -      return ConstIterator(*map, ItemIt(*graph));
   1.787 -    }
   1.788 -
   1.789 -    /// It gives back the const iterator pointed to the first invalid element.
   1.790 -    ConstIterator end() const {
   1.791 -      return ConstIterator(*map, ItemIt(INVALID));
   1.792 -    }
   1.793 -            
   1.794 -  public:
   1.795 -    // STL  compatibility typedefs.
   1.796 -    typedef Value value_type;
   1.797 -    typedef ConstIterator const_iterator;
   1.798 -    typedef ConstReference const_reference;
   1.799 -    typedef ConstPointer const_pointer;
   1.800 -    typedef int difference_type;
   1.801 -
   1.802 -  };
   1.803 -
   1.804 -  template <typename _Map>
   1.805 -  class IterableMapExtender : public _Map {
   1.806 -  public:
   1.807 -
   1.808 -    typedef _Map Parent;
   1.809 -    typedef Parent Map;
   1.810 -    typedef typename Map::Graph Graph;
   1.811 -    typedef typename Map::Key Item;
   1.812 -    typedef typename Map::Value Value;
   1.813 -
   1.814 -    typedef MapSet<Graph, Item, Map> MapSet;
   1.815 -
   1.816 -    IterableMapExtender() : Parent() {}
   1.817 -
   1.818 -    IterableMapExtender(const Graph& graph) : Parent(graph) {}
   1.819 -
   1.820 -    IterableMapExtender(const Graph& graph, const Value& value) 
   1.821 -      : Parent(graph, value) {}
   1.822 -
   1.823 -    MapSet mapSet() { 
   1.824 -      return MapSet(*Parent::getGraph(), *this); 
   1.825 -    }
   1.826 -
   1.827 -    typedef ConstMapSet<Graph, Item, Map> ConstMapSet;
   1.828 -
   1.829 -    ConstMapSet mapSet() const { 
   1.830 -      return ConstMapSet(*Parent::getGraph(), *this); 
   1.831 -    }
   1.832 -
   1.833 -    typedef MapConstKeySet<Graph, Item> ConstKeySet;
   1.834 - 
   1.835 -    ConstKeySet keySet() const {
   1.836 -      return ConstKeySet(*Parent::getGraph());
   1.837 -    }
   1.838 -
   1.839 -    typedef MapValueSet<Graph, Item, Map> ValueSet;
   1.840 - 
   1.841 -    ValueSet valueSet() {
   1.842 -      return ValueSet(*Parent::getGraph(), *this);
   1.843 -    }
   1.844 -
   1.845 -    typedef MapConstValueSet<Graph, Item, Map> ConstValueSet;
   1.846 - 
   1.847 -    ConstValueSet valueSet() const {
   1.848 -      return ConstValueSet(*Parent::getGraph(), *this);
   1.849 -    }
   1.850 -
   1.851 -  };
   1.852 -
   1.853 -  /// @}
   1.854 -
   1.855 -}
   1.856 -
   1.857 -#endif