src/hugo/map_iterator.h
changeset 875 fda944f15ca7
parent 830 89dfa3bece81
child 901 69a8e672acb1
equal deleted inserted replaced
1:e2a2eb53657f 2:f9012b139d76
     1 // -*- c++ -*-
     1 // -*- c++ -*-
     2 #ifndef MAP_ITERATOR_H
     2 #ifndef MAP_ITERATOR_H
     3 #define MAP_ITERATOR_H
     3 #define MAP_ITERATOR_H
       
     4 
       
     5 #include <iterator>
     4 
     6 
     5 #include <hugo/extended_pair.h>
     7 #include <hugo/extended_pair.h>
     6 
     8 
     7 ///\ingroup graphmaps
     9 ///\ingroup graphmaps
     8 ///\file
    10 ///\file
    20 
    22 
    21   template <typename Map>
    23   template <typename Map>
    22   class MapIteratorBase {
    24   class MapIteratorBase {
    23 
    25 
    24   public:
    26   public:
       
    27 
    25     /// The key type of the iterator.
    28     /// The key type of the iterator.
    26     typedef typename Map::KeyType KeyType;
    29     typedef typename Map::KeyType KeyType;
    27     /// The iterator to iterate on the keys.
    30     /// The iterator to iterate on the keys.
    28     typedef typename Map::KeyIt KeyIt;
    31     typedef typename Map::KeyIt KeyIt;
    29 
    32 
    77   template <typename Map>  
    80   template <typename Map>  
    78   class MapIterator : public MapIteratorBase<Map> {
    81   class MapIterator : public MapIteratorBase<Map> {
    79 
    82 
    80     friend class MapConstIterator<Map>;
    83     friend class MapConstIterator<Map>;
    81 
    84 
    82   public:
    85 
       
    86   public:
       
    87 
       
    88     /// The iterator base class.
       
    89     typedef MapIteratorBase<Map> Base;
    83 
    90 
    84     /// The key type of the iterator.
    91     /// The key type of the iterator.
    85     typedef typename Map::KeyType KeyType;
    92     typedef typename Map::KeyType KeyType;
    86     /// The iterator to iterate on the keys.
    93     /// The iterator to iterate on the keys.
    87     typedef typename Map::KeyIt KeyIt;
    94     typedef typename Map::KeyIt KeyIt;
    99     typedef typename Map::ConstReferenceType ConstReferenceType;
   106     typedef typename Map::ConstReferenceType ConstReferenceType;
   100     /// The pointer type of the iterator.
   107     /// The pointer type of the iterator.
   101     typedef typename Map::ConstPointerType ConstPointerType;
   108     typedef typename Map::ConstPointerType ConstPointerType;
   102     
   109     
   103   public:
   110   public:
       
   111 
       
   112     /// The value type of the iterator.
       
   113     typedef extended_pair<KeyType, const KeyType&,
       
   114       ValueType, const ValueType&> PairValueType;
   104 
   115 
   105     /// The reference type of the iterator. 
   116     /// The reference type of the iterator. 
   106     typedef extended_pair<const KeyType&, const KeyType&, 
   117     typedef extended_pair<const KeyType&, const KeyType&, 
   107       ReferenceType, ReferenceType> PairReferenceType;
   118       ReferenceType, ReferenceType> PairReferenceType;
   108 
   119 
   109     /// Default constructor. 
   120     /// Default constructor. 
   110     MapIterator() {}
   121     MapIterator() {}
   111 
   122 
   112     /// Constructor to initalize the iterators returned 
   123     /// Constructor to initalize the iterators returned 
   113     /// by the begin() and end().
   124     /// by the begin() and end().
   114     MapIterator(Map& pmap, const KeyIt& pit) 
   125     MapIterator(Map& pmap, const KeyIt& pit) : Base(pit), map(&pmap) {}
   115       : MapIteratorBase<Map>(pit), map(&pmap) {}
       
   116 
   126 
   117     /// Dereference operator for the iterator.
   127     /// Dereference operator for the iterator.
   118     PairReferenceType operator*() {
   128     PairReferenceType operator*() {
   119       return PairReferenceType(it, (*map)[it]);
   129       return PairReferenceType(Base::it, (*map)[Base::it]);
   120     }
   130     }
   121 
   131 
   122     /// The pointer type of the iterator.
   132     /// The pointer type of the iterator.
   123     class PairPointerType {
   133     class PairPointerType {
   124       friend class MapIterator;
   134       friend class MapIterator;
   130       PairReferenceType* operator->() {return &data;}
   140       PairReferenceType* operator->() {return &data;}
   131     };
   141     };
   132 
   142 
   133     /// Arrow operator for the iterator.
   143     /// Arrow operator for the iterator.
   134     PairPointerType operator->() {
   144     PairPointerType operator->() {
   135       return PairPointerType(it, ((*map)[it])); 
   145       return PairPointerType(Base::it, ((*map)[Base::it])); 
   136     }
   146     }
   137 	
   147 	
   138     /// The pre increment operator of the iterator.
   148     /// The pre increment operator of the iterator.
   139     MapIterator& operator++() { 
   149     MapIterator& operator++() { 
   140       increment(); 
   150       Base::increment(); 
   141       return *this; 
   151       return *this; 
   142     }
   152     }
   143 
   153 
   144     /// The post increment operator of the iterator.
   154     /// The post increment operator of the iterator.
   145     MapIterator operator++(int) { 
   155     MapIterator operator++(int) { 
   146       MapIterator tmp(it); 
   156       MapIterator tmp(*this); 
   147       increment(); 
   157       Base::increment(); 
   148       return tmp; 
   158       return tmp; 
   149     }
   159     }
   150 
   160 
   151   private:
   161   private:
   152     Map* map;
   162     Map* map;
       
   163 
       
   164   public:
       
   165     // STL  compatibility typedefs.
       
   166     typedef std::forward_iterator_tag iterator_category;
       
   167     typedef int difference_type;
       
   168     typedef PairValueType value_type;
       
   169     typedef PairReferenceType reference;
       
   170     typedef PairPointerType pointer;
   153   };
   171   };
   154 
   172 
   155   /** Compatible iterator with the stl maps' iterators.
   173   /** Compatible iterator with the stl maps' iterators.
   156    *  It iterates on pairs of a key and a value.
   174    *  It iterates on pairs of a key and a value.
   157    */
   175    */
   158   template <typename Map>
   176   template <typename Map>
   159   class MapConstIterator : public MapIteratorBase<Map> {
   177   class MapConstIterator : public MapIteratorBase<Map> {
   160     
   178     
   161   public:
   179   public:
       
   180 
       
   181     /// The iterator base class.
       
   182     typedef MapIteratorBase<Map> Base;
   162 
   183 
   163     /// The key type of the iterator.
   184     /// The key type of the iterator.
   164     typedef typename Map::KeyType KeyType;
   185     typedef typename Map::KeyType KeyType;
   165     /// The iterator to iterate on the keys.
   186     /// The iterator to iterate on the keys.
   166     typedef typename Map::KeyIt KeyIt;
   187     typedef typename Map::KeyIt KeyIt;
   185     MapConstIterator() {}
   206     MapConstIterator() {}
   186 
   207 
   187     /// Constructor to initalize the the iterators returned
   208     /// Constructor to initalize the the iterators returned
   188     ///  by the begin() and end().
   209     ///  by the begin() and end().
   189     MapConstIterator(const Map& pmap, const KeyIt& pit) 
   210     MapConstIterator(const Map& pmap, const KeyIt& pit) 
   190       : MapIteratorBase<Map>(pit), map(&pmap) {}
   211       : Base(pit), map(&pmap) {}
   191 
   212 
   192     /// Constructor to create const iterator from a non const.
   213     /// Constructor to create const iterator from a non const.
   193     MapConstIterator(const MapIterator<Map>& pit) {
   214     MapConstIterator(const MapIterator<Map>& pit) {
   194       it = pit.it;
   215       Base::it = pit.Base::it;
   195       map = pit.map;
   216       map = pit.map;
   196     }
   217     }
       
   218 
       
   219     /// The value type of the iterator.
       
   220     typedef extended_pair<KeyType, const KeyType&,
       
   221       ValueType, const ValueType&> PairValueType;
   197 
   222 
   198     /// The reference type of map.
   223     /// The reference type of map.
   199     typedef extended_pair<const KeyType&, const KeyType&, 
   224     typedef extended_pair<const KeyType&, const KeyType&, 
   200       ConstReferenceType, ConstReferenceType> PairReferenceType;
   225       ConstReferenceType, ConstReferenceType> PairReferenceType;
   201 
   226 
   202     /// Dereference operator for the iterator.
   227     /// Dereference operator for the iterator.
   203     PairReferenceType operator*() {
   228     PairReferenceType operator*() {
   204       return PairReferenceType(it, (*map)[it]);
   229       return PairReferenceType(Base::it, (*map)[Base::it]);
   205     }
   230     }
   206 
   231 
   207     /// The pointer type of the iterator.
   232     /// The pointer type of the iterator.
   208     class PairPointerType {
   233     class PairPointerType {
   209       friend class MapConstIterator;
   234       friend class MapConstIterator;
   215       PairReferenceType* operator->() {return &data;}
   240       PairReferenceType* operator->() {return &data;}
   216     };
   241     };
   217 
   242 
   218     /// Arrow operator for the iterator.
   243     /// Arrow operator for the iterator.
   219     PairPointerType operator->() {
   244     PairPointerType operator->() {
   220       return PairPointerType(it, ((*map)[it])); 
   245       return PairPointerType(Base::it, (*map)[Base::it]); 
   221     }
   246     }
   222 
   247 
   223     /// The pre increment operator of the iterator.
   248     /// The pre increment operator of the iterator.
   224     MapConstIterator& operator++() { 
   249     MapConstIterator& operator++() { 
   225       increment(); 
   250       Base::increment(); 
   226       return *this; 
   251       return *this; 
   227     }
   252     }
   228 
   253 
   229     /// The post increment operator of the iterator.
   254     /// The post increment operator of the iterator.
   230     MapConstIterator operator++(int) { 
   255     MapConstIterator operator++(int) { 
   231       MapConstIterator<Map> tmp(it); 
   256       MapConstIterator tmp(*this); 
   232       increment(); 
   257       Base::increment(); 
   233       return tmp; 
   258       return tmp; 
   234     }
   259     }
   235 
   260 
   236   private:
   261   private:
   237     const Map* map;
   262     const Map* map;
       
   263 
       
   264   public:
       
   265     // STL  compatibility typedefs.
       
   266     typedef std::input_iterator_tag iterator_category;
       
   267     typedef int difference_type;
       
   268     typedef PairValueType value_type;
       
   269     typedef PairReferenceType reference;
       
   270     typedef PairPointerType pointer;
   238   };
   271   };
   239 
   272 
   240   /** The class makes the KeyIt to an stl compatible iterator
   273   /** The class makes the KeyIt to an stl compatible iterator
   241    *  with dereferencing operator.
   274    *  with dereferencing operator.
   242    */
   275    */
   243   template <typename Map>
   276   template <typename Map>
   244   class MapKeyIterator : public MapIteratorBase<Map> {
   277   class MapKeyIterator : public MapIteratorBase<Map> {
   245 
   278 
   246   public:
   279   public:
   247 
   280 
       
   281     /// The iterator base class.
       
   282     typedef MapIteratorBase<Map> Base;
       
   283  
   248     /// The key type of the iterator.
   284     /// The key type of the iterator.
   249     typedef typename Map::KeyType KeyType;
   285     typedef typename Map::KeyType KeyType;
   250     /// The iterator to iterate on the keys.
   286     /// The iterator to iterate on the keys.
   251     typedef typename Map::KeyIt KeyIt;
   287     typedef typename Map::KeyIt KeyIt;
   252 
   288 
   254 
   290 
   255     /// Default constructor.
   291     /// Default constructor.
   256     MapKeyIterator() {}
   292     MapKeyIterator() {}
   257 
   293 
   258     /// KeyIt initialized iterator.
   294     /// KeyIt initialized iterator.
   259     MapKeyIterator(const KeyIt& pit) : MapIteratorBase<Map>(pit) {}
   295     MapKeyIterator(const KeyIt& pit) : Base(pit) {}
   260 
   296 
   261     /// The pre increment operator of the iterator.
   297     /// The pre increment operator of the iterator.
   262     MapKeyIterator& operator++() {
   298     MapKeyIterator& operator++() {
   263       increment(); 
   299       Base::increment(); 
   264       return *this; 
   300       return *this; 
   265     }
   301     }
   266 
   302 
   267     /// The post increment operator of the iterator.
   303     /// The post increment operator of the iterator.
   268     MapKeyIterator operator++(int) {
   304     MapKeyIterator operator++(int) {
   269       MapKeyIterator tmp(*this);
   305       MapKeyIterator tmp(*this);
   270       increment();
   306       Base::increment();
   271       return tmp;
   307       return tmp;
   272     }
   308     }
   273 
   309 
   274     /// The dereferencing operator of the iterator.
   310     /// The dereferencing operator of the iterator.
   275     KeyType operator*() const {
   311     KeyType operator*() const {
   276       return static_cast<KeyType>(it);
   312       return static_cast<KeyType>(Base::it);
   277     }
   313     }
       
   314 
       
   315   public:
       
   316     // STL  compatibility typedefs.
       
   317     typedef std::input_iterator_tag iterator_category;
       
   318     typedef int difference_type;
       
   319     typedef KeyType value_type;
       
   320     typedef const KeyType& reference;
       
   321     typedef const KeyType* pointer;
   278   };
   322   };
   279 
   323 
   280   template <typename Map> class MapConstValueIterator;
   324   template <typename Map> class MapConstValueIterator;
   281 
   325 
       
   326   /** MapValueIterator creates an stl compatible iterator
       
   327    *  for the values.
       
   328    */
   282   template <typename Map>
   329   template <typename Map>
   283   class MapValueIterator : public MapIteratorBase<Map> {
   330   class MapValueIterator : public MapIteratorBase<Map> {
   284 
   331 
   285     friend class MapConstValueIterator<Map>;
   332     friend class MapConstValueIterator<Map>;
   286 
   333 
   287   public:
   334   public:
       
   335 
       
   336     /// The iterator base class.
       
   337     typedef MapIteratorBase<Map> Base;
   288 
   338 
   289     /// The key type of the iterator.
   339     /// The key type of the iterator.
   290     typedef typename Map::KeyType KeyType;
   340     typedef typename Map::KeyType KeyType;
   291     /// The iterator to iterate on the keys.
   341     /// The iterator to iterate on the keys.
   292     typedef typename Map::KeyIt KeyIt;
   342     typedef typename Map::KeyIt KeyIt;
   315     /// Default constructor.
   365     /// Default constructor.
   316     MapValueIterator() {}
   366     MapValueIterator() {}
   317 
   367 
   318     /// Map and KeyIt initialized iterator.
   368     /// Map and KeyIt initialized iterator.
   319     MapValueIterator(Map& pmap, const KeyIt& pit) 
   369     MapValueIterator(Map& pmap, const KeyIt& pit) 
   320       : MapIteratorBase<Map>(pit), map(&pmap) {}
   370       : Base(pit), map(&pmap) {}
   321     
   371     
   322 
   372 
   323     /// The pre increment operator of the iterator.
   373     /// The pre increment operator of the iterator.
   324     MapValueIterator& operator++() {
   374     MapValueIterator& operator++() {
   325       increment(); 
   375       Base::increment(); 
   326       return *this; 
   376       return *this; 
   327     }
   377     }
   328 
   378 
   329     /// The post increment operator of the iterator.
   379     /// The post increment operator of the iterator.
   330     MapValueIterator operator++(int) {
   380     MapValueIterator operator++(int) {
   331       MapValueIterator tmp(*this);
   381       MapValueIterator tmp(*this);
   332       increment();
   382       Base::increment();
   333       return tmp;
   383       return tmp;
   334     }
   384     }
   335 
   385 
   336     /// The dereferencing operator of the iterator.
   386     /// The dereferencing operator of the iterator.
   337     ReferenceType operator*() const {
   387     ReferenceType operator*() const {
   338       return (*map)[it];
   388       return (*map)[Base::it];
   339     }
   389     }
   340 
   390 
   341     /// The arrow operator of the iterator.
   391     /// The arrow operator of the iterator.
   342     PointerType operator->() const {
   392     PointerType operator->() const {
   343       return &(operator*());
   393       return &(operator*());
   344     }
   394     }
   345 
   395 
   346   };
   396   public:
   347 
   397     // STL  compatibility typedefs.
       
   398     typedef std::forward_iterator_tag iterator_category;
       
   399     typedef int difference_type;
       
   400     typedef ValueType value_type;
       
   401     typedef ReferenceType reference;
       
   402     typedef PointerType pointer;
       
   403   };
       
   404 
       
   405   /** MapValueIterator creates an stl compatible iterator
       
   406    *  for the const values.
       
   407    */
   348 
   408 
   349   template <typename Map>
   409   template <typename Map>
   350   class MapConstValueIterator : public MapIteratorBase<Map> {
   410   class MapConstValueIterator : public MapIteratorBase<Map> {
   351 
   411 
   352   public:
   412   public:
   353 
   413 
   354     /// The key type of the iterator.
   414     /// The iterator base class.
   355     typedef typename Map::KeyType KeyType;
   415     typedef MapIteratorBase<Map> Base;
   356     /// The iterator to iterate on the keys.
   416 
   357     typedef typename Map::KeyIt KeyIt;
   417     /// The key type of the iterator.
   358 
   418     typedef typename Map::KeyType KeyType;
       
   419     /// The iterator to iterate on the keys.
       
   420     typedef typename Map::KeyIt KeyIt;
   359 
   421 
   360     /// The value type of the iterator.
   422     /// The value type of the iterator.
   361     typedef typename Map::ValueType ValueType;
   423     typedef typename Map::ValueType ValueType;
   362     /// The reference type of the iterator.
   424     /// The reference type of the iterator.
   363     typedef typename Map::ReferenceType ReferenceType;
   425     typedef typename Map::ReferenceType ReferenceType;
   380     /// Default constructor.
   442     /// Default constructor.
   381     MapConstValueIterator() {}
   443     MapConstValueIterator() {}
   382 
   444 
   383     /// Constructor to create const iterator from a non const.
   445     /// Constructor to create const iterator from a non const.
   384     MapConstValueIterator(const MapValueIterator<Map>& pit) {
   446     MapConstValueIterator(const MapValueIterator<Map>& pit) {
   385       it = pit.it;
   447       Base::it = pit.Base::it;
   386       map = pit.map;
   448       map = pit.map;
   387     }
   449     }
   388 
   450 
   389     /// Map and KeyIt initialized iterator.
   451     /// Map and KeyIt initialized iterator.
   390     MapConstValueIterator(const Map& pmap, const KeyIt& pit) 
   452     MapConstValueIterator(const Map& pmap, const KeyIt& pit) 
   391       : MapIteratorBase<Map>(pit), map(&pmap) {}
   453       : Base(pit), map(&pmap) {}
   392 
   454 
   393     /// The pre increment operator of the iterator.
   455     /// The pre increment operator of the iterator.
   394     MapConstValueIterator& operator++() {
   456     MapConstValueIterator& operator++() {
   395       increment(); 
   457       Base::increment(); 
   396       return *this; 
   458       return *this; 
   397     }
   459     }
   398 
   460 
   399     /// The post increment operator of the iterator.
   461     /// The post increment operator of the iterator.
   400     MapConstValueIterator operator++(int) {
   462     MapConstValueIterator operator++(int) {
   401       MapConstValueIterator tmp(*this);
   463       MapConstValueIterator tmp(*this);
   402       increment();
   464       Base::increment();
   403       return tmp;
   465       return tmp;
   404     }
   466     }
   405 
   467 
   406     /// The dereferencing operator of the iterator.
   468     /// The dereferencing operator of the iterator.
   407     ConstReferenceType operator*() const {
   469     ConstReferenceType operator*() const {
   408       return (*map)[it];
   470       return (*map)[Base::it];
   409     }
   471     }
   410 
   472 
   411     /// The arrow operator of the iterator.
   473     /// The arrow operator of the iterator.
   412     ConstPointerType operator->() const {
   474     ConstPointerType operator->() const {
   413       return &(operator*());
   475       return &(operator*());
   414     }
   476     }
   415 
   477 
       
   478   public:
       
   479     // STL  compatibility typedefs.
       
   480     typedef std::input_iterator_tag iterator_category;
       
   481     typedef int difference_type;
       
   482     typedef ValueType value_type;
       
   483     typedef ConstReferenceType reference;
       
   484     typedef ConstPointerType pointer;
   416   };
   485   };
   417 
   486 
   418 
   487 
   419   /** This class makes from a map an iteratable set
   488   /** This class makes from a map an iteratable set
   420    *  which contains all the keys of the map.
   489    *  which contains all the keys of the map.
   428 
   497 
   429     /// The key type of the iterator.
   498     /// The key type of the iterator.
   430     typedef typename Map::KeyType KeyType;
   499     typedef typename Map::KeyType KeyType;
   431     /// The iterator to iterate on the keys.
   500     /// The iterator to iterate on the keys.
   432     typedef typename Map::KeyIt KeyIt;
   501     typedef typename Map::KeyIt KeyIt;
       
   502 
       
   503 
       
   504     /// The value type of the iterator.
       
   505     typedef typename Map::ValueType ValueType;
       
   506     /// The reference type of the iterator.
       
   507     typedef typename Map::ReferenceType ReferenceType;
       
   508     /// The pointer type of the iterator.
       
   509     typedef typename Map::PointerType PointerType;
       
   510 
       
   511     /// The const value type of the iterator.
       
   512     typedef typename Map::ConstValueType ConstValueType;
       
   513     /// The const reference type of the iterator.
       
   514     typedef typename Map::ConstReferenceType ConstReferenceType;
       
   515     /// The pointer type of the iterator.
       
   516     typedef typename Map::ConstPointerType ConstPointerType;
   433 
   517 
   434     /// The map initialized const key set.
   518     /// The map initialized const key set.
   435     MapConstKeySet(const Map& pmap) : map(&pmap) {}
   519     MapConstKeySet(const Map& pmap) : map(&pmap) {}
   436 
   520 
   437     /// The const iterator of the set.
   521     /// The const iterator of the set.
   444             
   528             
   445     /// It gives back the const iterator pointed to the first ivalid element.
   529     /// It gives back the const iterator pointed to the first ivalid element.
   446     ConstIterator end() const {
   530     ConstIterator end() const {
   447       return ConstIterator(KeyIt(INVALID));
   531       return ConstIterator(KeyIt(INVALID));
   448     }
   532     }
       
   533  
       
   534   public:
       
   535     // STL  compatibility typedefs.
       
   536     typedef ValueType value_type;
       
   537     typedef ConstIterator const_iterator;
       
   538     typedef ConstReferenceType const_reference;
       
   539     typedef ConstPointerType const_pointer;
       
   540     typedef int difference_type;
   449   };
   541   };
   450 
   542 
   451   /** This class makes from a map an iteratable set
   543   /** This class makes from a map an iteratable set
   452    *  which contains all the values of the map.
   544    *  which contains all the values of the map.
   453    *  The values cannot be modified.
   545    *  The values cannot be modified.
   462     /// The key type of the iterator.
   554     /// The key type of the iterator.
   463     typedef typename Map::KeyType KeyType;
   555     typedef typename Map::KeyType KeyType;
   464     /// The iterator to iterate on the keys.
   556     /// The iterator to iterate on the keys.
   465     typedef typename Map::KeyIt KeyIt;
   557     typedef typename Map::KeyIt KeyIt;
   466 
   558 
       
   559 
       
   560     /// The value type of the iterator.
       
   561     typedef typename Map::ValueType ValueType;
       
   562     /// The reference type of the iterator.
       
   563     typedef typename Map::ReferenceType ReferenceType;
       
   564     /// The pointer type of the iterator.
       
   565     typedef typename Map::PointerType PointerType;
       
   566 
       
   567     /// The const value type of the iterator.
       
   568     typedef typename Map::ConstValueType ConstValueType;
       
   569     /// The const reference type of the iterator.
       
   570     typedef typename Map::ConstReferenceType ConstReferenceType;
       
   571     /// The pointer type of the iterator.
       
   572     typedef typename Map::ConstPointerType ConstPointerType;
       
   573 
   467     /// The map initialized const value set.
   574     /// The map initialized const value set.
   468     MapConstValueSet(const Map& pmap) : map(&pmap) {}
   575     MapConstValueSet(const Map& pmap) : map(&pmap) {}
   469 
   576 
   470     /// The const iterator of the set.
   577     /// The const iterator of the set.
   471     typedef MapConstValueIterator<Map> ConstIterator;
   578     typedef MapConstValueIterator<Map> ConstIterator;
   477 
   584 
   478     /// It gives back the const iterator pointed to the first invalid element.
   585     /// It gives back the const iterator pointed to the first invalid element.
   479     ConstIterator end() const {
   586     ConstIterator end() const {
   480       return ConstIterator(*map, KeyIt(INVALID));
   587       return ConstIterator(*map, KeyIt(INVALID));
   481     }
   588     }
       
   589 
       
   590   public:
       
   591     // STL  compatibility typedefs.
       
   592     typedef ValueType value_type;
       
   593     typedef ConstIterator const_iterator;
       
   594     typedef ConstReferenceType const_reference;
       
   595     typedef ConstPointerType const_pointer;
       
   596     typedef int difference_type;
   482   };
   597   };
   483 
   598 
   484 
   599 
   485   /** This class makes from a map an iteratable set
   600   /** This class makes from a map an iteratable set
   486    *  which contains all the values of the map.
   601    *  which contains all the values of the map.
   496     /// The key type of the iterator.
   611     /// The key type of the iterator.
   497     typedef typename Map::KeyType KeyType;
   612     typedef typename Map::KeyType KeyType;
   498     /// The iterator to iterate on the keys.
   613     /// The iterator to iterate on the keys.
   499     typedef typename Map::KeyIt KeyIt;
   614     typedef typename Map::KeyIt KeyIt;
   500 
   615 
       
   616 
       
   617     /// The value type of the iterator.
       
   618     typedef typename Map::ValueType ValueType;
       
   619     /// The reference type of the iterator.
       
   620     typedef typename Map::ReferenceType ReferenceType;
       
   621     /// The pointer type of the iterator.
       
   622     typedef typename Map::PointerType PointerType;
       
   623 
       
   624     /// The const value type of the iterator.
       
   625     typedef typename Map::ConstValueType ConstValueType;
       
   626     /// The const reference type of the iterator.
       
   627     typedef typename Map::ConstReferenceType ConstReferenceType;
       
   628     /// The pointer type of the iterator.
       
   629     typedef typename Map::ConstPointerType ConstPointerType;
       
   630 
   501     /// The map initialized value set.
   631     /// The map initialized value set.
   502     MapValueSet(Map& pmap) : map(&pmap) {}
   632     MapValueSet(Map& pmap) : map(&pmap) {}
   503 
   633 
   504     /// The const iterator of the set.
   634     /// The const iterator of the set.
   505     typedef MapConstValueIterator<Map> ConstIterator;
   635     typedef MapConstValueIterator<Map> ConstIterator;
   525     /// It gives back the iterator pointed to the first invalid element.
   655     /// It gives back the iterator pointed to the first invalid element.
   526     Iterator end() {
   656     Iterator end() {
   527       return Iterator(*map, KeyIt(INVALID));
   657       return Iterator(*map, KeyIt(INVALID));
   528     }
   658     }
   529             
   659             
       
   660   public:
       
   661     // STL  compatibility typedefs.
       
   662     typedef ValueType value_type;
       
   663     typedef Iterator iterator;
       
   664     typedef ConstIterator const_iterator;
       
   665     typedef ReferenceType reference;
       
   666     typedef ConstReferenceType const_reference;
       
   667     typedef PointerType pointer;
       
   668     typedef ConstPointerType const_pointer;
       
   669     typedef int difference_type;
       
   670 
   530   };
   671   };
   531 
   672 
   532   /// @}
   673   /// @}
   533 
   674 
   534 }
   675 }