COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/lemon/map_iterator.h @ 1284:b941d044f87b

Last change on this file since 1284:b941d044f87b was 1271:40e5d0d44a65, checked in by Balazs Dezso, 19 years ago

Some bug fix

File size: 21.1 KB
RevLine 
[906]1/* -*- C++ -*-
[921]2 * src/lemon/map_iterator.h - Part of LEMON, a generic C++ optimization library
[906]3 *
[1164]4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
[906]5 * (Egervary Combinatorial Optimization Research Group, EGRES).
6 *
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
10 *
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
13 * purpose.
14 *
15 */
16
[921]17#ifndef LEMON_MAP_ITERATOR_H
18#define LEMON_MAP_ITERATOR_H
[822]19
[844]20#include <iterator>
21
[921]22#include <lemon/extended_pair.h>
[1267]23#include <lemon/map_utils.h>
[822]24
[830]25///\ingroup graphmaps
26///\file
27///\brief Iterators on the maps.
28
[921]29namespace lemon {
[822]30
[830]31  /// \addtogroup graphmaps
32  /// @{
33
34  /** The base class all of the map iterators.
35   *  The class defines the typedefs of the iterators,
36   *  simple step functions and equality operators.
37   */
[822]38
[1267]39  template <
40    typename _Graph,
41    typename _Item>
[830]42  class MapIteratorBase {
[822]43
[830]44  protected:
45
[1267]46    /// The key type of the iterator.
47    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
48
49    ItemIt it;
[830]50
51    /// Default constructor.
52    MapIteratorBase() {}
53
[1267]54    /// ItemIt initialized MapIteratorBase constructor.
55    MapIteratorBase(const ItemIt _it) : it(_it) {}
[830]56
57  public:
58
59    /// Stepping forward in the map.   
60    void increment() {
61      ++it;
62    }
63
64    /// The equality operator of the map.
[1267]65    bool operator==(const MapIteratorBase& _it) const {
66      return _it.it == it;
[830]67    }
68       
69    /// The not-equality operator of the map.
[1267]70    bool operator!=(const MapIteratorBase& _it) const {
71      return !(*this == _it);
[830]72    }
73  };
74
[1267]75
76  template <
77    typename _Graph,
78    typename _Item,
79    typename _Map>
80  class MapConstIterator;
[822]81
82  /** Compatible iterator with the stl maps' iterators.
[830]83   * It iterates on pairs of a key and a value.
[822]84   */
[1267]85  template <
86    typename _Graph,
87    typename _Item,
88    typename _Map>
89  class MapIterator : public MapIteratorBase<_Graph, _Item> {
[830]90
[1267]91    friend class MapConstIterator<_Graph, _Item, _Map>;
[822]92
[844]93
[822]94  public:
95
[844]96    /// The iterator base class.
[1267]97    typedef MapIteratorBase<_Graph, _Item> Parent;
[844]98
[1267]99    typedef _Item Item;
100    typedef _Map Map;
101    typedef _Graph Graph;
[822]102
[1267]103  protected:
[822]104
[1267]105    typedef typename Parent::ItemIt ItemIt;
106
107    typedef typename ReferenceMapTraits<_Map>::Value MapValue;
108    typedef typename ReferenceMapTraits<_Map>::Reference MapReference;
[822]109   
110  public:
111
[844]112    /// The value type of the iterator.
[1267]113    typedef extended_pair<Item, const Item&,
114      MapValue, const MapValue&> Value;
[844]115
[830]116    /// The reference type of the iterator.
[1267]117    typedef extended_pair<const Item&, const Item&,
118      MapReference, MapReference> Reference;
[822]119
[830]120    /// Default constructor.
121    MapIterator() {}
122
123    /// Constructor to initalize the iterators returned
124    /// by the begin() and end().
[1267]125    MapIterator(Map& _map, const ItemIt& _it)
126      : Parent(_it), map(&_map) {}
[830]127
128    /// Dereference operator for the iterator.
[1267]129    Reference operator*() {
130      return Reference(Parent::it, (*map)[Parent::it]);
[822]131    }
132
[830]133    /// The pointer type of the iterator.
[1267]134    class Pointer {
[822]135      friend class MapIterator;
[1267]136    protected:
137      Reference data;
138      Pointer(const Item& item, MapReference val)
139        : data(item, val) {}
[822]140    public:
[1267]141      Reference* operator->() {return &data;}
[822]142    };
143
[830]144    /// Arrow operator for the iterator.
[1267]145    Pointer operator->() {
146      return Pointer(Parent::it, (*map)[Parent::it]);
[822]147    }
[830]148       
149    /// The pre increment operator of the iterator.
[822]150    MapIterator& operator++() {
[1267]151      Parent::increment();
[822]152      return *this;
153    }
154
[830]155    /// The post increment operator of the iterator.
[822]156    MapIterator operator++(int) {
[844]157      MapIterator tmp(*this);
[1267]158      Parent::increment();
[822]159      return tmp;
160    }
161
[1267]162  protected:
163
[822]164    Map* map;
[844]165
166  public:
167    // STL  compatibility typedefs.
168    typedef std::forward_iterator_tag iterator_category;
169    typedef int difference_type;
[1267]170    typedef Value value_type;
171    typedef Reference reference;
172    typedef Pointer pointer;
[822]173  };
174
175  /** Compatible iterator with the stl maps' iterators.
176   *  It iterates on pairs of a key and a value.
177   */
[1267]178  template <
179    typename _Graph,
180    typename _Item,
181    typename _Map>
182  class MapConstIterator : public MapIteratorBase<_Graph, _Item> {
183
184  public:
185
186    /// The iterator base class.
187    typedef MapIteratorBase<_Graph, _Item> Parent;
188
189    typedef _Graph Graph;
190    typedef _Item Item;
191    typedef _Map Map;
192
193  protected:
194
195    typedef typename Parent::ItemIt ItemIt;
196
197    typedef typename ReferenceMapTraits<_Map>::Value MapValue;
198    typedef typename ReferenceMapTraits<_Map>::ConstReference
199    MapReference;
[830]200   
[822]201  public:
202
[1267]203    /// The value type of the iterator.
204    typedef extended_pair<Item, const Item&,
205      MapValue, const MapValue&> Value;
[844]206
[1267]207    /// The reference type of the iterator.
208    typedef extended_pair<const Item&, const Item&,
209      MapReference, MapReference> Reference;
[822]210
[830]211    /// Default constructor.
[822]212    MapConstIterator() {}
213
[1267]214    /// Constructor to initalize the iterators returned
215    /// by the begin() and end().
216    MapConstIterator(const Map& _map, const ItemIt& _it)
217      : Parent(_it), map(&_map) {}
[822]218
[830]219    /// Dereference operator for the iterator.
[1267]220    Reference operator*() {
221      return Reference(Parent::it, (*map)[Parent::it]);
[822]222    }
223
[830]224    /// The pointer type of the iterator.
[1267]225    class Pointer {
[822]226      friend class MapConstIterator;
[1267]227    protected:
228      Reference data;
229      Pointer(const Item& item, MapReference val)
230        : data(item, val) {}
[822]231    public:
[1267]232      Reference* operator->() {return &data;}
[822]233    };
234
[830]235    /// Arrow operator for the iterator.
[1267]236    Pointer operator->() {
237      return Pointer(Parent::it, ((*map)[Parent::it]));
[822]238    }
[1267]239       
[830]240    /// The pre increment operator of the iterator.
[822]241    MapConstIterator& operator++() {
[1267]242      Parent::increment();
[822]243      return *this;
244    }
245
[830]246    /// The post increment operator of the iterator.
[822]247    MapConstIterator operator++(int) {
[844]248      MapConstIterator tmp(*this);
[1267]249      Parent::increment();
[822]250      return tmp;
251    }
252
[1267]253  protected:
[830]254    const Map* map;
[844]255
256  public:
257    // STL  compatibility typedefs.
[1267]258    typedef std::forward_iterator_tag iterator_category;
[844]259    typedef int difference_type;
[1267]260    typedef Value value_type;
261    typedef Reference reference;
262    typedef Pointer pointer;
[830]263  };
[1267]264 
265  /** The class makes the ItemIt to an stl compatible iterator
[830]266   *  with dereferencing operator.
267   */
[1267]268  template <
269    typename _Graph,
270    typename _Item>
271  class MapConstKeyIterator : public MapIteratorBase<_Graph, _Item> {
[830]272
273  public:
274
[844]275    /// The iterator base class.
[1267]276    typedef MapIteratorBase<_Graph, _Item> Parent;
[844]277 
[1267]278    typedef _Graph Graph;
279    typedef _Item Item;
280
281  protected:
[830]282    /// The iterator to iterate on the keys.
[1267]283    typedef typename Parent::ItemIt ItemIt;
[830]284
285  public:
286
[1267]287    typedef Item Value;
288    typedef const Item& Reference;
289    typedef const Item* Pointer;
290
[830]291    /// Default constructor.
[1267]292    MapConstKeyIterator() {}
[830]293
[1267]294    /// ItemIt initialized iterator.
295    MapConstKeyIterator(const ItemIt& pit) : Parent(pit) {}
[830]296
297    /// The pre increment operator of the iterator.
[1267]298    MapConstKeyIterator& operator++() {
299      Parent::increment();
[830]300      return *this;
[822]301    }
302
[830]303    /// The post increment operator of the iterator.
[1267]304    MapConstKeyIterator operator++(int) {
305      MapConstKeyIterator tmp(*this);
306      Parent::increment();
[830]307      return tmp;
[822]308    }
[830]309
310    /// The dereferencing operator of the iterator.
[1267]311    Item operator*() const {
312      return static_cast<Item>(Parent::it);
[822]313    }
[844]314
315  public:
316    // STL  compatibility typedefs.
317    typedef std::input_iterator_tag iterator_category;
318    typedef int difference_type;
[1267]319    typedef Value value_type;
320    typedef Reference reference;
321    typedef Pointer pointer;
[830]322  };
323
[1267]324  template <
325    typename _Graph,
326    typename _Item,
327    typename _Map>
328  class MapConstValueIterator;
[830]329
[844]330  /** MapValueIterator creates an stl compatible iterator
331   *  for the values.
332   */
[1267]333  template <
334    typename _Graph,
335    typename _Item,
336    typename _Map>
337  class MapValueIterator : public MapIteratorBase<_Graph, _Item> {
[830]338
[1267]339    friend class MapConstValueIterator<_Graph, _Item, _Map>;
[830]340
341  public:
342
[844]343    /// The iterator base class.
[1267]344    typedef MapIteratorBase<_Graph, _Item> Parent;
[844]345
[1267]346    typedef _Graph Graph;
347    typedef _Item Item;
348    typedef _Map Map;
349
350  protected:
351
[830]352    /// The iterator to iterate on the keys.
[1267]353    typedef typename Parent::ItemIt ItemIt;
[830]354
355    /// The value type of the iterator.
[1267]356    typedef typename ReferenceMapTraits<Map>::Value MapValue;
[830]357    /// The reference type of the iterator.
[1267]358    typedef typename ReferenceMapTraits<Map>::Reference MapReference;
[830]359    /// The pointer type of the iterator.
[1267]360    typedef typename ReferenceMapTraits<Map>::Pointer MapPointer;
[830]361
362  public:
363
[1267]364    typedef MapValue Value;
365    typedef MapReference Reference;
366    typedef MapPointer Pointer;
367
[830]368    /// Default constructor.
369    MapValueIterator() {}
370
[1267]371    /// Map and ItemIt initialized iterator.
372    MapValueIterator(Map& _map, const ItemIt& _it)
373      : Parent(_it), map(&_map) {}
[830]374   
375
376    /// The pre increment operator of the iterator.
377    MapValueIterator& operator++() {
[1267]378      Parent::increment();
[830]379      return *this;
380    }
381
382    /// The post increment operator of the iterator.
383    MapValueIterator operator++(int) {
384      MapValueIterator tmp(*this);
[1267]385      Parent::increment();
[830]386      return tmp;
387    }
388
389    /// The dereferencing operator of the iterator.
[987]390    Reference operator*() const {
[1267]391      return (*map)[Parent::it];
[830]392    }
393
394    /// The arrow operator of the iterator.
[987]395    Pointer operator->() const {
[830]396      return &(operator*());
397    }
398
[1267]399  protected:
400
401    Map* map;
402
[844]403  public:
404    // STL  compatibility typedefs.
405    typedef std::forward_iterator_tag iterator_category;
406    typedef int difference_type;
[987]407    typedef Value value_type;
408    typedef Reference reference;
409    typedef Pointer pointer;
[830]410  };
411
[844]412  /** MapValueIterator creates an stl compatible iterator
[1267]413   *  for the values.
[844]414   */
[1267]415  template <
416    typename _Graph,
417    typename _Item,
418    typename _Map>
419  class MapConstValueIterator : public MapIteratorBase<_Graph, _Item> {
[830]420
421  public:
422
[844]423    /// The iterator base class.
[1267]424    typedef MapIteratorBase<_Graph, _Item> Parent;
[844]425
[1267]426    typedef _Graph Graph;
427    typedef _Item Item;
428    typedef _Map Map;
429
430  protected:
431
[830]432    /// The iterator to iterate on the keys.
[1267]433    typedef typename Parent::ItemIt ItemIt;
[830]434
435    /// The value type of the iterator.
[1267]436    typedef typename ReferenceMapTraits<Map>::Value MapValue;
[830]437    /// The reference type of the iterator.
[1267]438    typedef typename ReferenceMapTraits<Map>::ConstReference MapReference;
[830]439    /// The pointer type of the iterator.
[1267]440    typedef typename ReferenceMapTraits<Map>::ConstPointer MapPointer;
[830]441
442  public:
443
[1267]444    typedef MapValue Value;
445    typedef MapReference Reference;
446    typedef MapPointer Pointer;
447
[830]448    /// Default constructor.
449    MapConstValueIterator() {}
450
[1267]451    /// Map and ItemIt initialized iterator.
452    MapConstValueIterator(const Map& _map, const ItemIt& _it)
453      : Parent(_it), map(&_map) {}
454   
[830]455
456    /// The pre increment operator of the iterator.
457    MapConstValueIterator& operator++() {
[1267]458      Parent::increment();
[830]459      return *this;
460    }
461
462    /// The post increment operator of the iterator.
463    MapConstValueIterator operator++(int) {
464      MapConstValueIterator tmp(*this);
[1267]465      Parent::increment();
[830]466      return tmp;
467    }
468
469    /// The dereferencing operator of the iterator.
[1267]470    Reference operator*() const {
471      return (*map)[Parent::it];
[830]472    }
473
474    /// The arrow operator of the iterator.
[1267]475    Pointer operator->() const {
[830]476      return &(operator*());
477    }
478
[1267]479  protected:
480
481    const Map* map;
482
[844]483  public:
484    // STL  compatibility typedefs.
[1267]485    typedef std::forward_iterator_tag iterator_category;
[844]486    typedef int difference_type;
[987]487    typedef Value value_type;
[1267]488    typedef Reference reference;
489    typedef Pointer pointer;
[822]490  };
491
[830]492
493  /** This class makes from a map an iteratable set
494   *  which contains all the keys of the map.
495   */
[1267]496  template <typename _Graph, typename _Item>
[830]497  class MapConstKeySet {
498
499  public:
500
[1267]501    typedef _Graph Graph;
[830]502    /// The key type of the iterator.
[1267]503    typedef _Item Item;
[830]504    /// The iterator to iterate on the keys.
505
[1267]506  protected:
[844]507
[1267]508    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
[844]509
[1267]510  public:
[844]511
[830]512    /// The map initialized const key set.
[1267]513    MapConstKeySet(const Graph& _graph) : graph(&_graph) {}
[830]514
515    /// The const iterator of the set.
[1267]516    typedef MapConstKeyIterator<_Graph, _Item> ConstIterator;
517
518    typedef typename ConstIterator::Value Value;
519    /// The reference type of the iterator.
520    typedef typename ConstIterator::Reference ConstReference;
521    /// The pointer type of the iterator.
522    typedef typename ConstIterator::Pointer ConstPointer;
[830]523
524    /// It gives back the const iterator pointed to the first element.
525    ConstIterator begin() const {
[1267]526      return ConstIterator(ItemIt(*graph));
[830]527    }
528           
529    /// It gives back the const iterator pointed to the first ivalid element.
530    ConstIterator end() const {
[1267]531      return ConstIterator(ItemIt(INVALID));
[830]532    }
[1267]533
534  protected:
535
536    const Graph* graph;
[844]537 
538  public:
539    // STL  compatibility typedefs.
[987]540    typedef Value value_type;
[844]541    typedef ConstIterator const_iterator;
[987]542    typedef ConstReference const_reference;
543    typedef ConstPointer const_pointer;
[844]544    typedef int difference_type;
[830]545  };
546
547  /** This class makes from a map an iteratable set
548   *  which contains all the values of the map.
549   *  The values cannot be modified.
550   */
[1267]551  template <typename _Graph, typename _Item, typename _Map>
[830]552  class MapConstValueSet {
553
[1267]554  public:
555   
556    typedef _Graph Graph;
557    typedef _Item Item;
558    typedef _Map Map;
559
560  protected:
561
562    /// The iterator to iterate on the keys.
563    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
[830]564
565  public:
566
567    /// The map initialized const value set.
[1267]568    MapConstValueSet(const Graph& _graph, const Map& _map)
569      : graph(&_graph), map(&_map) {}
[830]570
571    /// The const iterator of the set.
[1267]572    typedef MapConstValueIterator<_Graph, _Item, _Map> ConstIterator;
573
574    typedef typename ConstIterator::Value Value;
575    typedef typename ConstIterator::Reference ConstReference;
576    typedef typename ConstIterator::Pointer ConstPointer;
[830]577
578    /// It gives back the const iterator pointed to the first element.
579    ConstIterator begin() const {
[1267]580      return ConstIterator(*map, ItemIt(*graph));
[830]581    }
582
583    /// It gives back the const iterator pointed to the first invalid element.
584    ConstIterator end() const {
[1267]585      return ConstIterator(*map, ItemIt(INVALID));
[830]586    }
[844]587
[1267]588  protected:
589   
590    const Map* map;
591    const Graph * graph;
592
[844]593  public:
594    // STL  compatibility typedefs.
[987]595    typedef Value value_type;
[844]596    typedef ConstIterator const_iterator;
[987]597    typedef ConstReference const_reference;
598    typedef ConstPointer const_pointer;
[844]599    typedef int difference_type;
[830]600  };
601
602
603  /** This class makes from a map an iteratable set
604   *  which contains all the values of the map.
605   *  The values can be modified.
606   */
[1267]607  template <typename _Graph, typename _Item, typename _Map>
[830]608  class MapValueSet {
609
[1267]610  public:
611   
612    typedef _Graph Graph;
613    typedef _Item Item;
614    typedef _Map Map;
615
616  protected:
617
618    /// The iterator to iterate on the keys.
619    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
[830]620
621  public:
622
[1267]623    /// The map initialized const value set.
624    MapValueSet(const Graph& _graph, Map& _map)
[1271]625      : map(&_map), graph(&_graph) {}
[830]626
627    /// The const iterator of the set.
[1267]628    typedef MapValueIterator<_Graph, _Item, _Map> Iterator;
629    /// The const iterator of the set.
630    typedef MapConstValueIterator<_Graph, _Item, _Map> ConstIterator;
631
632    typedef typename ConstIterator::Value Value;
633    typedef typename Iterator::Reference Reference;
634    typedef typename Iterator::Pointer Pointer;
635    typedef typename ConstIterator::Reference ConstReference;
636    typedef typename ConstIterator::Pointer ConstPointer;
[830]637
638    /// It gives back the const iterator pointed to the first element.
639    ConstIterator begin() const {
[1267]640      return ConstIterator(*map, ItemIt(*graph));
[830]641    }
642
643    /// It gives back the const iterator pointed to the first invalid element.
644    ConstIterator end() const {
[1267]645      return ConstIterator(*map, ItemIt(INVALID));
[830]646    }
647
648    /// It gives back the iterator pointed to the first element.
649    Iterator begin() {
[1267]650      return Iterator(*map, ItemIt(*graph));
[830]651    }
652
653    /// It gives back the iterator pointed to the first invalid element.
654    Iterator end() {
[1267]655      return Iterator(*map, ItemIt(INVALID));
[830]656    }
[1267]657
658  protected:
659   
660    Map* map;
661    const Graph * graph;
662
663  public:
664    // STL  compatibility typedefs.
665    typedef Value value_type;
666    typedef Iterator iterator;
667    typedef ConstIterator const_iterator;
668    typedef Reference reference;
669    typedef ConstReference const_reference;
670    typedef Pointer pointer;
671    typedef ConstPointer const_pointer;
672    typedef int difference_type;
673
674  };
675
676  /** This class makes from a map an iteratable set
677   *  which contains all the values of the map.
678   *  The values can be modified.
679   */
680  template <
681    typename _Graph,
682    typename _Item,
683    typename _Map
684    >
685  class MapSet {
686  public:   
687
688    typedef _Graph Graph;
689    typedef _Item Item;
690    typedef _Map Map;
691
692  protected:
693
694    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
695
696  public:
697
698    /// The map initialized value set.
699    MapSet(const Graph& _graph, Map& _map) : graph(&_graph), map(&_map) {}
700
701    /// The const iterator of the set.
702    typedef MapIterator<_Graph, _Item, _Map> Iterator;
703    typedef MapConstIterator<_Graph, _Item, _Map> ConstIterator;
704
705    typedef typename ConstIterator::Value Value;
706    typedef typename Iterator::Reference Reference;
707    typedef typename Iterator::Pointer Pointer;
708    typedef typename ConstIterator::Reference ConstReference;
709    typedef typename ConstIterator::Pointer ConstPointer;
710
711
712    /// It gives back the const iterator pointed to the first element.
713    ConstIterator begin() const {
714      return ConstIterator(*map, ItemIt(*graph));
715    }
716
717    /// It gives back the const iterator pointed to the first invalid element.
718    ConstIterator end() const {
719      return ConstIterator(*map, ItemIt(INVALID));
720    }
721
722    /// The iterator of the set.
723
724    /// It gives back the iterator pointed to the first element.
725    Iterator begin() {
726      return Iterator(*map, ItemIt(*graph));
727    }
728
729    /// It gives back the iterator pointed to the first invalid element.
730    Iterator end() {
731      return Iterator(*map, ItemIt(INVALID));
732    }
733
734  protected:
735   
736    const Graph* graph;
737    Map* map;
[830]738           
[844]739  public:
740    // STL  compatibility typedefs.
[987]741    typedef Value value_type;
[844]742    typedef Iterator iterator;
743    typedef ConstIterator const_iterator;
[987]744    typedef Reference reference;
745    typedef ConstReference const_reference;
746    typedef Pointer pointer;
747    typedef ConstPointer const_pointer;
[844]748    typedef int difference_type;
749
[830]750  };
751
[1267]752  template <
753    typename _Graph,
754    typename _Item,
755    typename _Map
756    >
757  class ConstMapSet {
758   
759    typedef _Graph Graph;
760    typedef _Map Map;
761
762    const Graph* graph;
763    const Map* map;
764
765  public:
766
767    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
768
769
770    /// The map initialized value set.
771    ConstMapSet(const Graph& _graph, const Map& _map)
772      : graph(&_graph), map(&_map) {}
773
774    /// The const iterator of the set.
775    typedef MapConstIterator<_Graph, _Item, _Map> ConstIterator;
776
777    typedef typename ConstIterator::Value Value;
778    typedef typename ConstIterator::Reference ConstReference;
779    typedef typename ConstIterator::Pointer ConstPointer;
780
781
782    /// It gives back the const iterator pointed to the first element.
783    ConstIterator begin() const {
784      return ConstIterator(*map, ItemIt(*graph));
785    }
786
787    /// It gives back the const iterator pointed to the first invalid element.
788    ConstIterator end() const {
789      return ConstIterator(*map, ItemIt(INVALID));
790    }
791           
792  public:
793    // STL  compatibility typedefs.
794    typedef Value value_type;
795    typedef ConstIterator const_iterator;
796    typedef ConstReference const_reference;
797    typedef ConstPointer const_pointer;
798    typedef int difference_type;
799
800  };
801
802  template <typename _Map>
803  class IterableMapExtender : public _Map {
804  public:
805
806    typedef _Map Parent;
807    typedef Parent Map;
808    typedef typename Map::Graph Graph;
809    typedef typename Map::Key Item;
810    typedef typename Map::Value Value;
811
812    typedef MapSet<Graph, Item, Map> MapSet;
813
814    IterableMapExtender() : Parent() {}
815
816    IterableMapExtender(const Graph& graph) : Parent(graph) {}
817
818    IterableMapExtender(const Graph& graph, const Value& value)
819      : Parent(graph, value) {}
820
821    MapSet mapSet() {
822      return MapSet(*Parent::getGraph(), *this);
823    }
824
825    typedef ConstMapSet<Graph, Item, Map> ConstMapSet;
826
827    ConstMapSet mapSet() const {
828      return ConstMapSet(*Parent::getGraph(), *this);
829    }
830
831    typedef MapConstKeySet<Graph, Item> ConstKeySet;
832 
833    ConstKeySet keySet() const {
834      return ConstKeySet(*Parent::getGraph());
835    }
836
837    typedef MapValueSet<Graph, Item, Map> ValueSet;
838 
839    ValueSet valueSet() {
840      return ValueSet(*Parent::getGraph(), *this);
841    }
842
843    typedef MapConstValueSet<Graph, Item, Map> ConstValueSet;
844 
845    ConstValueSet valueSet() const {
846      return ConstValueSet(*Parent::getGraph(), *this);
847    }
848
849  };
850
[830]851  /// @}
852
[822]853}
854
855#endif
Note: See TracBrowser for help on using the repository browser.