Modified iterators on graph maps
authordeba
Wed, 16 Nov 2005 18:58:10 +0000
changeset 1810474d093466a5
parent 1809 029cc4f638d1
child 1811 597ce92fae73
Modified iterators on graph maps
Other iterators for not graph maps
lemon/bits/array_map.h
lemon/bits/map_extender.h
lemon/bits/map_iterator.h
lemon/bits/static_map.h
lemon/bits/vector_map.h
lemon/iterable_maps.h
lemon/lp_base.h
lemon/map_iterator.h
     1.1 --- a/lemon/bits/array_map.h	Wed Nov 16 14:46:22 2005 +0000
     1.2 +++ b/lemon/bits/array_map.h	Wed Nov 16 18:58:10 2005 +0000
     1.3 @@ -18,7 +18,7 @@
     1.4  #define LEMON_ARRAY_MAP_H
     1.5  
     1.6  #include <memory>
     1.7 -#include <lemon/bits/map_iterator.h>
     1.8 +#include <lemon/bits/map_extender.h>
     1.9  #include <lemon/concept_check.h>
    1.10  #include <lemon/concept/maps.h>
    1.11  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lemon/bits/map_extender.h	Wed Nov 16 18:58:10 2005 +0000
     2.3 @@ -0,0 +1,115 @@
     2.4 +/* -*- C++ -*-
     2.5 + * lemon/map_extender.h - Part of LEMON, a generic C++ optimization library
     2.6 + *
     2.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     2.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
     2.9 + *
    2.10 + * Permission to use, modify and distribute this software is granted
    2.11 + * provided that this copyright notice appears in all copies. For
    2.12 + * precise terms see the accompanying LICENSE file.
    2.13 + *
    2.14 + * This software is provided "AS IS" with no warranty of any kind,
    2.15 + * express or implied, and with no claim as to its suitability for any
    2.16 + * purpose.
    2.17 + *
    2.18 + */
    2.19 +
    2.20 +#ifndef LEMON_BITS_MAP_EXTENDER_H
    2.21 +#define LEMON_BITS_MAP_EXTENDER_H
    2.22 +
    2.23 +#include <iterator>
    2.24 +
    2.25 +#include <lemon/traits.h>
    2.26 +
    2.27 +///\file
    2.28 +///\brief Extenders for iterable maps.
    2.29 +
    2.30 +namespace lemon {
    2.31 +
    2.32 +  template <typename _Map>
    2.33 +  class IterableMapExtender : public _Map {
    2.34 +  public:
    2.35 +
    2.36 +    typedef _Map Parent;
    2.37 +    typedef IterableMapExtender Map;
    2.38 +
    2.39 +
    2.40 +    typedef typename Map::Graph Graph;
    2.41 +    typedef typename Map::Key Item;
    2.42 +
    2.43 +    typedef typename Map::Key Key;
    2.44 +    typedef typename Map::Value Value;
    2.45 +
    2.46 +    class MapIt;
    2.47 +    class ConstMapIt;
    2.48 +
    2.49 +    friend class MapIt;
    2.50 +    friend class ConstMapIt;
    2.51 +
    2.52 +  protected:
    2.53 +
    2.54 +    using Parent::getGraph;
    2.55 +
    2.56 +  public:
    2.57 +
    2.58 +    IterableMapExtender(const Graph& graph) : Parent(graph) {}
    2.59 +
    2.60 +    IterableMapExtender(const Graph& graph, const Value& value) 
    2.61 +      : Parent(graph, value) {}
    2.62 +
    2.63 +
    2.64 +    class MapIt : public ItemSetTraits<Graph, Item>::ItemIt {
    2.65 +    public:
    2.66 +      
    2.67 +      typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
    2.68 +
    2.69 +      typedef typename Map::Value Value;
    2.70 +      
    2.71 +      MapIt(Map& _map) : Parent(*_map.getGraph()), map(_map) {}
    2.72 +      
    2.73 +      typename MapTraits<Map>::ConstReturnValue operator*() const {
    2.74 +	return map[*this];
    2.75 +      }
    2.76 +
    2.77 +      typename MapTraits<Map>::ReturnValue operator*() {
    2.78 +	return map[*this];
    2.79 +      }
    2.80 +      
    2.81 +      void set(const Value& value) {
    2.82 +	map.set(*this, value);
    2.83 +      }
    2.84 +      
    2.85 +    protected:
    2.86 +      Map& map;
    2.87 +      
    2.88 +    };
    2.89 +
    2.90 +    class ConstMapIt : public ItemSetTraits<Graph, Key>::ItemIt {
    2.91 +    public:
    2.92 +
    2.93 +      typedef typename ItemSetTraits<Graph, Key>::ItemIt Parent;
    2.94 +
    2.95 +      typedef typename Map::Value Value;
    2.96 +
    2.97 +      ConstMapIt(const Map& _map) : Parent(*_map.getGraph()), map(_map) {}
    2.98 +
    2.99 +      typename MapTraits<Map>::ConstReturnValue operator*() const {
   2.100 +	return map[*this];
   2.101 +      }
   2.102 +    protected:
   2.103 +      const Map& map;
   2.104 +    };
   2.105 +
   2.106 +    class ItemIt : public ItemSetTraits<Graph, Key>::ItemIt {
   2.107 +    public:
   2.108 +      
   2.109 +      typedef typename ItemSetTraits<Graph, Key>::ItemIt Parent;
   2.110 +
   2.111 +      ItemIt(Map& _map) : Parent(*_map.getGraph()) {}
   2.112 +      
   2.113 +    };
   2.114 +  };
   2.115 +
   2.116 +}
   2.117 +
   2.118 +#endif
     3.1 --- a/lemon/bits/map_iterator.h	Wed Nov 16 14:46:22 2005 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,854 +0,0 @@
     3.4 -/* -*- C++ -*-
     3.5 - * lemon/map_iterator.h - Part of LEMON, a generic C++ optimization library
     3.6 - *
     3.7 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     3.8 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
     3.9 - *
    3.10 - * Permission to use, modify and distribute this software is granted
    3.11 - * provided that this copyright notice appears in all copies. For
    3.12 - * precise terms see the accompanying LICENSE file.
    3.13 - *
    3.14 - * This software is provided "AS IS" with no warranty of any kind,
    3.15 - * express or implied, and with no claim as to its suitability for any
    3.16 - * purpose.
    3.17 - *
    3.18 - */
    3.19 -
    3.20 -#ifndef LEMON_MAP_ITERATOR_H
    3.21 -#define LEMON_MAP_ITERATOR_H
    3.22 -
    3.23 -#include <iterator>
    3.24 -
    3.25 -#include <lemon/bits/extended_pair.h>
    3.26 -#include <lemon/graph_utils.h>
    3.27 -
    3.28 -///\ingroup graphmapfactory
    3.29 -///\file
    3.30 -///\brief Iterators on the maps.
    3.31 -
    3.32 -namespace lemon {
    3.33 -
    3.34 -  /// \addtogroup graphmapfactory
    3.35 -  /// @{
    3.36 -
    3.37 -  /** The base class all of the map iterators.
    3.38 -   *  The class defines the typedefs of the iterators,
    3.39 -   *  simple step functions and equality operators.
    3.40 -   */ 
    3.41 -
    3.42 -  template <
    3.43 -    typename _Graph,
    3.44 -    typename _Item>
    3.45 -  class MapIteratorBase {
    3.46 -
    3.47 -  protected:
    3.48 -
    3.49 -    /// The key type of the iterator.
    3.50 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
    3.51 -
    3.52 -    ItemIt it;
    3.53 -
    3.54 -    /// Default constructor.
    3.55 -    MapIteratorBase() {}
    3.56 -
    3.57 -    /// ItemIt initialized MapIteratorBase constructor.
    3.58 -    MapIteratorBase(const ItemIt _it) : it(_it) {}
    3.59 -
    3.60 -  public:
    3.61 -
    3.62 -    /// Stepping forward in the map.   
    3.63 -    void increment() { 
    3.64 -      ++it; 
    3.65 -    }
    3.66 -
    3.67 -    /// The equality operator of the map.
    3.68 -    bool operator==(const MapIteratorBase& _it) const {
    3.69 -      return _it.it == it;
    3.70 -    }
    3.71 -	
    3.72 -    /// The not-equality operator of the map.
    3.73 -    bool operator!=(const MapIteratorBase& _it) const {
    3.74 -      return !(*this == _it);
    3.75 -    }
    3.76 -  };
    3.77 -
    3.78 -
    3.79 -  template <
    3.80 -    typename _Graph,
    3.81 -    typename _Item,
    3.82 -    typename _Map>
    3.83 -  class MapConstIterator;
    3.84 -
    3.85 -  /** Compatible iterator with the stl maps' iterators.
    3.86 -   * It iterates on pairs of a key and a value.
    3.87 -   */
    3.88 -  template <
    3.89 -    typename _Graph,
    3.90 -    typename _Item,
    3.91 -    typename _Map>
    3.92 -  class MapIterator : public MapIteratorBase<_Graph, _Item> {
    3.93 -
    3.94 -    friend class MapConstIterator<_Graph, _Item, _Map>;
    3.95 -
    3.96 -
    3.97 -  public:
    3.98 -
    3.99 -    /// The iterator base class.
   3.100 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   3.101 -
   3.102 -    typedef _Item Item;
   3.103 -    typedef _Map Map;
   3.104 -    typedef _Graph Graph;
   3.105 -
   3.106 -  protected:
   3.107 -
   3.108 -    typedef typename Parent::ItemIt ItemIt;
   3.109 -
   3.110 -    typedef typename _Map::Value MapValue;
   3.111 -    typedef typename _Map::Reference MapReference;
   3.112 -    
   3.113 -  public:
   3.114 -
   3.115 -    /// The value type of the iterator.
   3.116 -    typedef extended_pair<Item, const Item&,
   3.117 -      MapValue, const MapValue&> Value;
   3.118 -
   3.119 -    /// The reference type of the iterator. 
   3.120 -    typedef extended_pair<const Item&, const Item&, 
   3.121 -      MapReference, MapReference> Reference;
   3.122 -
   3.123 -    /// Default constructor. 
   3.124 -    MapIterator() {}
   3.125 -
   3.126 -    /// Constructor to initalize the iterators returned 
   3.127 -    /// by the begin() and end().
   3.128 -    MapIterator(Map& _map, const ItemIt& _it) 
   3.129 -      : Parent(_it), map(&_map) {}
   3.130 -
   3.131 -    /// Dereference operator for the iterator.
   3.132 -    Reference operator*() {
   3.133 -      return Reference(Parent::it, (*map)[Parent::it]);
   3.134 -    }
   3.135 -
   3.136 -    /// The pointer type of the iterator.
   3.137 -    class Pointer {
   3.138 -      friend class MapIterator;
   3.139 -    protected:
   3.140 -      Reference data;
   3.141 -      Pointer(const Item& item, MapReference val) 
   3.142 -	: data(item, val) {}
   3.143 -    public:
   3.144 -      Reference* operator->() {return &data;}
   3.145 -    };
   3.146 -
   3.147 -    /// Arrow operator for the iterator.
   3.148 -    Pointer operator->() {
   3.149 -      return Pointer(Parent::it, (*map)[Parent::it]); 
   3.150 -    }
   3.151 -	
   3.152 -    /// The pre increment operator of the iterator.
   3.153 -    MapIterator& operator++() { 
   3.154 -      Parent::increment(); 
   3.155 -      return *this; 
   3.156 -    }
   3.157 -
   3.158 -    /// The post increment operator of the iterator.
   3.159 -    MapIterator operator++(int) { 
   3.160 -      MapIterator tmp(*this); 
   3.161 -      Parent::increment(); 
   3.162 -      return tmp; 
   3.163 -    }
   3.164 -
   3.165 -  protected:
   3.166 -
   3.167 -    Map* map;
   3.168 -
   3.169 -  public:
   3.170 -    // STL  compatibility typedefs.
   3.171 -    typedef std::forward_iterator_tag iterator_category;
   3.172 -    typedef int difference_type;
   3.173 -    typedef Value value_type;
   3.174 -    typedef Reference reference;
   3.175 -    typedef Pointer pointer;
   3.176 -  };
   3.177 -
   3.178 -  /** Compatible iterator with the stl maps' iterators.
   3.179 -   *  It iterates on pairs of a key and a value.
   3.180 -   */
   3.181 -  template <
   3.182 -    typename _Graph,
   3.183 -    typename _Item,
   3.184 -    typename _Map>
   3.185 -  class MapConstIterator : public MapIteratorBase<_Graph, _Item> {
   3.186 -
   3.187 -  public:
   3.188 -
   3.189 -    /// The iterator base class.
   3.190 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   3.191 -
   3.192 -    typedef _Graph Graph;
   3.193 -    typedef _Item Item;
   3.194 -    typedef _Map Map;
   3.195 -
   3.196 -  protected:
   3.197 -
   3.198 -    typedef typename Parent::ItemIt ItemIt;
   3.199 -
   3.200 -    typedef typename _Map::Value MapValue;
   3.201 -    typedef typename _Map::ConstReference MapReference;
   3.202 -    
   3.203 -  public:
   3.204 -
   3.205 -    /// The value type of the iterator.
   3.206 -    typedef extended_pair<Item, const Item&,
   3.207 -      MapValue, const MapValue&> Value;
   3.208 -
   3.209 -    /// The reference type of the iterator. 
   3.210 -    typedef extended_pair<const Item&, const Item&, 
   3.211 -      MapReference, MapReference> Reference;
   3.212 -
   3.213 -    /// Default constructor. 
   3.214 -    MapConstIterator() {}
   3.215 -
   3.216 -    /// Constructor to initalize the iterators returned 
   3.217 -    /// by the begin() and end().
   3.218 -    MapConstIterator(const Map& _map, const ItemIt& _it) 
   3.219 -      : Parent(_it), map(&_map) {}
   3.220 -
   3.221 -    /// Dereference operator for the iterator.
   3.222 -    Reference operator*() {
   3.223 -      return Reference(Parent::it, (*map)[Parent::it]);
   3.224 -    }
   3.225 -
   3.226 -    /// The pointer type of the iterator.
   3.227 -    class Pointer {
   3.228 -      friend class MapConstIterator;
   3.229 -    protected:
   3.230 -      Reference data;
   3.231 -      Pointer(const Item& item, MapReference val) 
   3.232 -	: data(item, val) {}
   3.233 -    public:
   3.234 -      Reference* operator->() {return &data;}
   3.235 -    };
   3.236 -
   3.237 -    /// Arrow operator for the iterator.
   3.238 -    Pointer operator->() {
   3.239 -      return Pointer(Parent::it, ((*map)[Parent::it])); 
   3.240 -    }
   3.241 -	
   3.242 -    /// The pre increment operator of the iterator.
   3.243 -    MapConstIterator& operator++() { 
   3.244 -      Parent::increment(); 
   3.245 -      return *this; 
   3.246 -    }
   3.247 -
   3.248 -    /// The post increment operator of the iterator.
   3.249 -    MapConstIterator operator++(int) { 
   3.250 -      MapConstIterator tmp(*this); 
   3.251 -      Parent::increment(); 
   3.252 -      return tmp; 
   3.253 -    }
   3.254 -
   3.255 -  protected:
   3.256 -    const Map* map;
   3.257 -
   3.258 -  public:
   3.259 -    // STL  compatibility typedefs.
   3.260 -    typedef std::forward_iterator_tag iterator_category;
   3.261 -    typedef int difference_type;
   3.262 -    typedef Value value_type;
   3.263 -    typedef Reference reference;
   3.264 -    typedef Pointer pointer;
   3.265 -  };
   3.266 - 
   3.267 -  /** The class makes the ItemIt to an stl compatible iterator
   3.268 -   *  with dereferencing operator.
   3.269 -   */
   3.270 -  template <
   3.271 -    typename _Graph,
   3.272 -    typename _Item>
   3.273 -  class MapConstKeyIterator : public MapIteratorBase<_Graph, _Item> {
   3.274 -
   3.275 -  public:
   3.276 -
   3.277 -    /// The iterator base class.
   3.278 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   3.279 - 
   3.280 -    typedef _Graph Graph;
   3.281 -    typedef _Item Item;
   3.282 -
   3.283 -  protected:
   3.284 -    /// The iterator to iterate on the keys.
   3.285 -    typedef typename Parent::ItemIt ItemIt;
   3.286 -
   3.287 -  public:
   3.288 -
   3.289 -    typedef Item Value;
   3.290 -    typedef const Item& Reference;
   3.291 -    typedef const Item* Pointer;
   3.292 -
   3.293 -    /// Default constructor.
   3.294 -    MapConstKeyIterator() {}
   3.295 -
   3.296 -    /// ItemIt initialized iterator.
   3.297 -    MapConstKeyIterator(const ItemIt& pit) : Parent(pit) {}
   3.298 -
   3.299 -    /// The pre increment operator of the iterator.
   3.300 -    MapConstKeyIterator& operator++() {
   3.301 -      Parent::increment(); 
   3.302 -      return *this; 
   3.303 -    }
   3.304 -
   3.305 -    /// The post increment operator of the iterator.
   3.306 -    MapConstKeyIterator operator++(int) {
   3.307 -      MapConstKeyIterator tmp(*this);
   3.308 -      Parent::increment();
   3.309 -      return tmp;
   3.310 -    }
   3.311 -
   3.312 -    /// The dereferencing operator of the iterator.
   3.313 -    Item operator*() const {
   3.314 -      return static_cast<Item>(Parent::it);
   3.315 -    }
   3.316 -
   3.317 -  public:
   3.318 -    // STL  compatibility typedefs.
   3.319 -    typedef std::input_iterator_tag iterator_category;
   3.320 -    typedef int difference_type;
   3.321 -    typedef Value value_type;
   3.322 -    typedef Reference reference;
   3.323 -    typedef Pointer pointer;
   3.324 -  };
   3.325 -
   3.326 -  template <
   3.327 -    typename _Graph, 
   3.328 -    typename _Item,
   3.329 -    typename _Map>
   3.330 -  class MapConstValueIterator;
   3.331 -
   3.332 -  /** MapValueIterator creates an stl compatible iterator
   3.333 -   *  for the values.
   3.334 -   */
   3.335 -  template <
   3.336 -    typename _Graph,
   3.337 -    typename _Item,
   3.338 -    typename _Map>
   3.339 -  class MapValueIterator : public MapIteratorBase<_Graph, _Item> {
   3.340 -
   3.341 -    friend class MapConstValueIterator<_Graph, _Item, _Map>;
   3.342 -
   3.343 -  public:
   3.344 -
   3.345 -    /// The iterator base class.
   3.346 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   3.347 -
   3.348 -    typedef _Graph Graph;
   3.349 -    typedef _Item Item;
   3.350 -    typedef _Map Map;
   3.351 -
   3.352 -  protected:
   3.353 -
   3.354 -    /// The iterator to iterate on the keys.
   3.355 -    typedef typename Parent::ItemIt ItemIt;
   3.356 -
   3.357 -    /// The value type of the iterator.
   3.358 -    typedef typename Map::Value MapValue;
   3.359 -    /// The reference type of the iterator.
   3.360 -    typedef typename Map::Reference MapReference;
   3.361 -    /// The pointer type of the iterator.
   3.362 -    typedef typename Map::Pointer MapPointer;
   3.363 -
   3.364 -  public:
   3.365 -
   3.366 -    typedef MapValue Value;
   3.367 -    typedef MapReference Reference;
   3.368 -    typedef MapPointer Pointer;
   3.369 -
   3.370 -    /// Default constructor.
   3.371 -    MapValueIterator() {}
   3.372 -
   3.373 -    /// Map and ItemIt initialized iterator.
   3.374 -    MapValueIterator(Map& _map, const ItemIt& _it) 
   3.375 -      : Parent(_it), map(&_map) {}
   3.376 -    
   3.377 -
   3.378 -    /// The pre increment operator of the iterator.
   3.379 -    MapValueIterator& operator++() {
   3.380 -      Parent::increment(); 
   3.381 -      return *this; 
   3.382 -    }
   3.383 -
   3.384 -    /// The post increment operator of the iterator.
   3.385 -    MapValueIterator operator++(int) {
   3.386 -      MapValueIterator tmp(*this);
   3.387 -      Parent::increment();
   3.388 -      return tmp;
   3.389 -    }
   3.390 -
   3.391 -    /// The dereferencing operator of the iterator.
   3.392 -    Reference operator*() const {
   3.393 -      return (*map)[Parent::it];
   3.394 -    }
   3.395 -
   3.396 -    /// The arrow operator of the iterator.
   3.397 -    Pointer operator->() const {
   3.398 -      return &(operator*());
   3.399 -    }
   3.400 -
   3.401 -  protected:
   3.402 -
   3.403 -    Map* map;
   3.404 -
   3.405 -  public:
   3.406 -    // STL  compatibility typedefs.
   3.407 -    typedef std::forward_iterator_tag iterator_category;
   3.408 -    typedef int difference_type;
   3.409 -    typedef Value value_type;
   3.410 -    typedef Reference reference;
   3.411 -    typedef Pointer pointer;
   3.412 -  };
   3.413 -
   3.414 -  /** MapValueIterator creates an stl compatible iterator
   3.415 -   *  for the values.
   3.416 -   */
   3.417 -  template <
   3.418 -    typename _Graph,
   3.419 -    typename _Item,
   3.420 -    typename _Map>
   3.421 -  class MapConstValueIterator : public MapIteratorBase<_Graph, _Item> {
   3.422 -
   3.423 -  public:
   3.424 -
   3.425 -    /// The iterator base class.
   3.426 -    typedef MapIteratorBase<_Graph, _Item> Parent;
   3.427 -
   3.428 -    typedef _Graph Graph;
   3.429 -    typedef _Item Item;
   3.430 -    typedef _Map Map;
   3.431 -
   3.432 -  protected:
   3.433 -
   3.434 -    /// The iterator to iterate on the keys.
   3.435 -    typedef typename Parent::ItemIt ItemIt;
   3.436 -
   3.437 -    /// The value type of the iterator.
   3.438 -    typedef typename Map::Value MapValue;
   3.439 -    /// The reference type of the iterator.
   3.440 -    typedef typename Map::ConstReference MapReference;
   3.441 -    /// The pointer type of the iterator.
   3.442 -    typedef typename Map::ConstPointer MapPointer;
   3.443 -
   3.444 -  public:
   3.445 -
   3.446 -    typedef MapValue Value;
   3.447 -    typedef MapReference Reference;
   3.448 -    typedef MapPointer Pointer;
   3.449 -
   3.450 -    /// Default constructor.
   3.451 -    MapConstValueIterator() {}
   3.452 -
   3.453 -    /// Map and ItemIt initialized iterator.
   3.454 -    MapConstValueIterator(const Map& _map, const ItemIt& _it) 
   3.455 -      : Parent(_it), map(&_map) {}
   3.456 -    
   3.457 -
   3.458 -    /// The pre increment operator of the iterator.
   3.459 -    MapConstValueIterator& operator++() {
   3.460 -      Parent::increment(); 
   3.461 -      return *this; 
   3.462 -    }
   3.463 -
   3.464 -    /// The post increment operator of the iterator.
   3.465 -    MapConstValueIterator operator++(int) {
   3.466 -      MapConstValueIterator tmp(*this);
   3.467 -      Parent::increment();
   3.468 -      return tmp;
   3.469 -    }
   3.470 -
   3.471 -    /// The dereferencing operator of the iterator.
   3.472 -    Reference operator*() const {
   3.473 -      return (*map)[Parent::it];
   3.474 -    }
   3.475 -
   3.476 -    /// The arrow operator of the iterator.
   3.477 -    Pointer operator->() const {
   3.478 -      return &(operator*());
   3.479 -    }
   3.480 -
   3.481 -  protected:
   3.482 -
   3.483 -    const Map* map;
   3.484 -
   3.485 -  public:
   3.486 -    // STL  compatibility typedefs.
   3.487 -    typedef std::forward_iterator_tag iterator_category;
   3.488 -    typedef int difference_type;
   3.489 -    typedef Value value_type;
   3.490 -    typedef Reference reference;
   3.491 -    typedef Pointer pointer;
   3.492 -  };
   3.493 -
   3.494 -
   3.495 -  /** This class makes from a map an iteratable set
   3.496 -   *  which contains all the keys of the map.
   3.497 -   */
   3.498 -  template <typename _Graph, typename _Item>
   3.499 -  class MapConstKeySet {
   3.500 -
   3.501 -  public:
   3.502 -
   3.503 -    typedef _Graph Graph;
   3.504 -    /// The key type of the iterator.
   3.505 -    typedef _Item Item;
   3.506 -    /// The iterator to iterate on the keys.
   3.507 -
   3.508 -  protected:
   3.509 -
   3.510 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
   3.511 -
   3.512 -  public:
   3.513 -
   3.514 -    /// The map initialized const key set.
   3.515 -    MapConstKeySet(const Graph& _graph) : graph(&_graph) {}
   3.516 -
   3.517 -    /// The const iterator of the set.
   3.518 -    typedef MapConstKeyIterator<_Graph, _Item> ConstIterator;
   3.519 -
   3.520 -    typedef typename ConstIterator::Value Value;
   3.521 -    /// The reference type of the iterator.
   3.522 -    typedef typename ConstIterator::Reference ConstReference;
   3.523 -    /// The pointer type of the iterator.
   3.524 -    typedef typename ConstIterator::Pointer ConstPointer;
   3.525 -
   3.526 -    /// It gives back the const iterator pointed to the first element.
   3.527 -    ConstIterator begin() const {
   3.528 -      return ConstIterator(ItemIt(*graph));
   3.529 -    }
   3.530 -            
   3.531 -    /// It gives back the const iterator pointed to the first ivalid element.
   3.532 -    ConstIterator end() const {
   3.533 -      return ConstIterator(ItemIt(INVALID));
   3.534 -    }
   3.535 -
   3.536 -  protected:
   3.537 -
   3.538 -    const Graph* graph;
   3.539 - 
   3.540 -  public:
   3.541 -    // STL  compatibility typedefs.
   3.542 -    typedef Value value_type;
   3.543 -    typedef ConstIterator const_iterator;
   3.544 -    typedef ConstReference const_reference;
   3.545 -    typedef ConstPointer const_pointer;
   3.546 -    typedef int difference_type;
   3.547 -  };
   3.548 -
   3.549 -  /** This class makes from a map an iteratable set
   3.550 -   *  which contains all the values of the map.
   3.551 -   *  The values cannot be modified.
   3.552 -   */
   3.553 -  template <typename _Graph, typename _Item, typename _Map>
   3.554 -  class MapConstValueSet {
   3.555 -
   3.556 -  public:
   3.557 -    
   3.558 -    typedef _Graph Graph;
   3.559 -    typedef _Item Item;
   3.560 -    typedef _Map Map;
   3.561 -
   3.562 -  protected:
   3.563 -
   3.564 -    /// The iterator to iterate on the keys.
   3.565 -    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
   3.566 -
   3.567 -  public:
   3.568 -
   3.569 -    /// The map initialized const value set.
   3.570 -    MapConstValueSet(const Graph& _graph, const Map& _map) 
   3.571 -      : graph(&_graph), map(&_map) {}
   3.572 -
   3.573 -    /// The const iterator of the set.
   3.574 -    typedef MapConstValueIterator<_Graph, _Item, _Map> ConstIterator;
   3.575 -
   3.576 -    typedef typename ConstIterator::Value Value;
   3.577 -    typedef typename ConstIterator::Reference ConstReference;
   3.578 -    typedef typename ConstIterator::Pointer ConstPointer;
   3.579 -
   3.580 -    /// It gives back the const iterator pointed to the first element.
   3.581 -    ConstIterator begin() const {
   3.582 -      return ConstIterator(*map, ItemIt(*graph));
   3.583 -    }
   3.584 -
   3.585 -    /// It gives back the const iterator pointed to the first invalid element.
   3.586 -    ConstIterator end() const {
   3.587 -      return ConstIterator(*map, ItemIt(INVALID));
   3.588 -    }
   3.589 -
   3.590 -  protected:
   3.591 -    
   3.592 -    const Map* map;
   3.593 -    const Graph * graph;
   3.594 -
   3.595 -  public:
   3.596 -    // STL  compatibility typedefs.
   3.597 -    typedef Value value_type;
   3.598 -    typedef ConstIterator const_iterator;
   3.599 -    typedef ConstReference const_reference;
   3.600 -    typedef ConstPointer const_pointer;
   3.601 -    typedef int difference_type;
   3.602 -  };
   3.603 -
   3.604 -
   3.605 -  /** This class makes from a map an iteratable set
   3.606 -   *  which contains all the values of the map.
   3.607 -   *  The values can be modified.
   3.608 -   */
   3.609 -  template <typename _Graph, typename _Item, typename _Map>
   3.610 -  class MapValueSet {
   3.611 -
   3.612 -  public:
   3.613 -    
   3.614 -    typedef _Graph Graph;
   3.615 -    typedef _Item Item;
   3.616 -    typedef _Map Map;
   3.617 -
   3.618 -  protected:
   3.619 -
   3.620 -    /// The iterator to iterate on the keys.
   3.621 -    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
   3.622 -
   3.623 -  public:
   3.624 -
   3.625 -    /// The map initialized const value set.
   3.626 -    MapValueSet(const Graph& _graph, Map& _map) 
   3.627 -      : map(&_map), graph(&_graph) {}
   3.628 -
   3.629 -    /// The const iterator of the set.
   3.630 -    typedef MapValueIterator<_Graph, _Item, _Map> Iterator;
   3.631 -    /// The const iterator of the set.
   3.632 -    typedef MapConstValueIterator<_Graph, _Item, _Map> ConstIterator;
   3.633 -
   3.634 -    typedef typename ConstIterator::Value Value;
   3.635 -    typedef typename Iterator::Reference Reference;
   3.636 -    typedef typename Iterator::Pointer Pointer;
   3.637 -    typedef typename ConstIterator::Reference ConstReference;
   3.638 -    typedef typename ConstIterator::Pointer ConstPointer;
   3.639 -
   3.640 -    /// It gives back the const iterator pointed to the first element.
   3.641 -    ConstIterator begin() const {
   3.642 -      return ConstIterator(*map, ItemIt(*graph));
   3.643 -    }
   3.644 -
   3.645 -    /// It gives back the const iterator pointed to the first invalid element.
   3.646 -    ConstIterator end() const {
   3.647 -      return ConstIterator(*map, ItemIt(INVALID));
   3.648 -    }
   3.649 -
   3.650 -    /// It gives back the iterator pointed to the first element.
   3.651 -    Iterator begin() {
   3.652 -      return Iterator(*map, ItemIt(*graph));
   3.653 -    }
   3.654 -
   3.655 -    /// It gives back the iterator pointed to the first invalid element.
   3.656 -    Iterator end() {
   3.657 -      return Iterator(*map, ItemIt(INVALID));
   3.658 -    }
   3.659 -
   3.660 -  protected:
   3.661 -    
   3.662 -    Map* map;
   3.663 -    const Graph * graph;
   3.664 -
   3.665 -  public:
   3.666 -    // STL  compatibility typedefs.
   3.667 -    typedef Value value_type;
   3.668 -    typedef Iterator iterator;
   3.669 -    typedef ConstIterator const_iterator;
   3.670 -    typedef Reference reference;
   3.671 -    typedef ConstReference const_reference;
   3.672 -    typedef Pointer pointer;
   3.673 -    typedef ConstPointer const_pointer;
   3.674 -    typedef int difference_type;
   3.675 -
   3.676 -  };
   3.677 -
   3.678 -  /** This class makes from a map an iteratable set
   3.679 -   *  which contains all the values of the map.
   3.680 -   *  The values can be modified.
   3.681 -   */
   3.682 -  template <
   3.683 -    typename _Graph, 
   3.684 -    typename _Item,
   3.685 -    typename _Map
   3.686 -    >
   3.687 -  class MapSet {
   3.688 -  public:    
   3.689 -
   3.690 -    typedef _Graph Graph;
   3.691 -    typedef _Item Item;
   3.692 -    typedef _Map Map;
   3.693 -
   3.694 -  protected:
   3.695 -
   3.696 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
   3.697 -
   3.698 -  public:
   3.699 -
   3.700 -    /// The map initialized value set.
   3.701 -    MapSet(const Graph& _graph, Map& _map) : graph(&_graph), map(&_map) {}
   3.702 -
   3.703 -    /// The const iterator of the set.
   3.704 -    typedef MapIterator<_Graph, _Item, _Map> Iterator;
   3.705 -    typedef MapConstIterator<_Graph, _Item, _Map> ConstIterator;
   3.706 -
   3.707 -    typedef typename ConstIterator::Value Value;
   3.708 -    typedef typename Iterator::Reference Reference;
   3.709 -    typedef typename Iterator::Pointer Pointer;
   3.710 -    typedef typename ConstIterator::Reference ConstReference;
   3.711 -    typedef typename ConstIterator::Pointer ConstPointer;
   3.712 -
   3.713 -
   3.714 -    /// It gives back the const iterator pointed to the first element.
   3.715 -    ConstIterator begin() const {
   3.716 -      return ConstIterator(*map, ItemIt(*graph));
   3.717 -    }
   3.718 -
   3.719 -    /// It gives back the const iterator pointed to the first invalid element.
   3.720 -    ConstIterator end() const {
   3.721 -      return ConstIterator(*map, ItemIt(INVALID));
   3.722 -    }
   3.723 -
   3.724 -    /// The iterator of the set.
   3.725 -
   3.726 -    /// It gives back the iterator pointed to the first element.
   3.727 -    Iterator begin() {
   3.728 -      return Iterator(*map, ItemIt(*graph));
   3.729 -    }
   3.730 -
   3.731 -    /// It gives back the iterator pointed to the first invalid element.
   3.732 -    Iterator end() {
   3.733 -      return Iterator(*map, ItemIt(INVALID));
   3.734 -    }
   3.735 -
   3.736 -  protected:
   3.737 -    
   3.738 -    const Graph* graph;
   3.739 -    Map* map;
   3.740 -            
   3.741 -  public:
   3.742 -    // STL  compatibility typedefs.
   3.743 -    typedef Value value_type;
   3.744 -    typedef Iterator iterator;
   3.745 -    typedef ConstIterator const_iterator;
   3.746 -    typedef Reference reference;
   3.747 -    typedef ConstReference const_reference;
   3.748 -    typedef Pointer pointer;
   3.749 -    typedef ConstPointer const_pointer;
   3.750 -    typedef int difference_type;
   3.751 -
   3.752 -  };
   3.753 -
   3.754 -  template <
   3.755 -    typename _Graph, 
   3.756 -    typename _Item,
   3.757 -    typename _Map
   3.758 -    >
   3.759 -  class ConstMapSet {
   3.760 -    
   3.761 -    typedef _Graph Graph;
   3.762 -    typedef _Map Map;
   3.763 -
   3.764 -    const Graph* graph;
   3.765 -    const Map* map;
   3.766 -
   3.767 -  public:
   3.768 -
   3.769 -    typedef typename ItemSetTraits<_Graph, _Item>::ItemIt ItemIt;
   3.770 -
   3.771 -
   3.772 -    /// The map initialized value set.
   3.773 -    ConstMapSet(const Graph& _graph, const Map& _map) 
   3.774 -      : graph(&_graph), map(&_map) {}
   3.775 -
   3.776 -    /// The const iterator of the set.
   3.777 -    typedef MapConstIterator<_Graph, _Item, _Map> ConstIterator;
   3.778 -
   3.779 -    typedef typename ConstIterator::Value Value;
   3.780 -    typedef typename ConstIterator::Reference ConstReference;
   3.781 -    typedef typename ConstIterator::Pointer ConstPointer;
   3.782 -
   3.783 -
   3.784 -    /// It gives back the const iterator pointed to the first element.
   3.785 -    ConstIterator begin() const {
   3.786 -      return ConstIterator(*map, ItemIt(*graph));
   3.787 -    }
   3.788 -
   3.789 -    /// It gives back the const iterator pointed to the first invalid element.
   3.790 -    ConstIterator end() const {
   3.791 -      return ConstIterator(*map, ItemIt(INVALID));
   3.792 -    }
   3.793 -            
   3.794 -  public:
   3.795 -    // STL  compatibility typedefs.
   3.796 -    typedef Value value_type;
   3.797 -    typedef ConstIterator const_iterator;
   3.798 -    typedef ConstReference const_reference;
   3.799 -    typedef ConstPointer const_pointer;
   3.800 -    typedef int difference_type;
   3.801 -
   3.802 -  };
   3.803 -
   3.804 -  template <typename _Map>
   3.805 -  class IterableMapExtender : public _Map {
   3.806 -  public:
   3.807 -
   3.808 -    typedef _Map Parent;
   3.809 -    typedef Parent Map;
   3.810 -    typedef typename Map::Graph Graph;
   3.811 -    typedef typename Map::Key Item;
   3.812 -    typedef typename Map::Value Value;
   3.813 -
   3.814 -    typedef MapSet<Graph, Item, Map> MapSet;
   3.815 -
   3.816 -    IterableMapExtender() : Parent() {}
   3.817 -
   3.818 -    IterableMapExtender(const Graph& graph) : Parent(graph) {}
   3.819 -
   3.820 -    IterableMapExtender(const Graph& graph, const Value& value) 
   3.821 -      : Parent(graph, value) {}
   3.822 -
   3.823 -    MapSet mapSet() { 
   3.824 -      return MapSet(*Parent::getGraph(), *this); 
   3.825 -    }
   3.826 -
   3.827 -    typedef ConstMapSet<Graph, Item, Map> ConstMapSet;
   3.828 -
   3.829 -    ConstMapSet mapSet() const { 
   3.830 -      return ConstMapSet(*Parent::getGraph(), *this); 
   3.831 -    }
   3.832 -
   3.833 -    typedef MapConstKeySet<Graph, Item> ConstKeySet;
   3.834 - 
   3.835 -    ConstKeySet keySet() const {
   3.836 -      return ConstKeySet(*Parent::getGraph());
   3.837 -    }
   3.838 -
   3.839 -    typedef MapValueSet<Graph, Item, Map> ValueSet;
   3.840 - 
   3.841 -    ValueSet valueSet() {
   3.842 -      return ValueSet(*Parent::getGraph(), *this);
   3.843 -    }
   3.844 -
   3.845 -    typedef MapConstValueSet<Graph, Item, Map> ConstValueSet;
   3.846 - 
   3.847 -    ConstValueSet valueSet() const {
   3.848 -      return ConstValueSet(*Parent::getGraph(), *this);
   3.849 -    }
   3.850 -
   3.851 -  };
   3.852 -
   3.853 -  /// @}
   3.854 -
   3.855 -}
   3.856 -
   3.857 -#endif
     4.1 --- a/lemon/bits/static_map.h	Wed Nov 16 14:46:22 2005 +0000
     4.2 +++ b/lemon/bits/static_map.h	Wed Nov 16 18:58:10 2005 +0000
     4.3 @@ -21,7 +21,7 @@
     4.4  #include <iostream>
     4.5  
     4.6  #include <lemon/utility.h>
     4.7 -#include <lemon/bits/map_iterator.h>
     4.8 +#include <lemon/bits/map_extender.h>
     4.9  #include <lemon/bits/alteration_notifier.h>
    4.10  #include <lemon/error.h>
    4.11  #include <lemon/concept_check.h>
     5.1 --- a/lemon/bits/vector_map.h	Wed Nov 16 14:46:22 2005 +0000
     5.2 +++ b/lemon/bits/vector_map.h	Wed Nov 16 18:58:10 2005 +0000
     5.3 @@ -21,7 +21,7 @@
     5.4  #include <algorithm>
     5.5  
     5.6  #include <lemon/utility.h>
     5.7 -#include <lemon/bits/map_iterator.h>
     5.8 +#include <lemon/bits/map_extender.h>
     5.9  #include <lemon/bits/alteration_notifier.h>
    5.10  #include <lemon/concept_check.h>
    5.11  #include <lemon/concept/maps.h>
     6.1 --- a/lemon/iterable_maps.h	Wed Nov 16 14:46:22 2005 +0000
     6.2 +++ b/lemon/iterable_maps.h	Wed Nov 16 18:58:10 2005 +0000
     6.3 @@ -136,11 +136,9 @@
     6.4      explicit IterableBoolMap(BaseMap &_m,bool init=false) : cref(_m)
     6.5      {
     6.6        sep=0;
     6.7 -      for(typename BaseMap::MapSet::iterator i=cref.mapSet().begin();
     6.8 -	  i!=cref.mapSet().end();
     6.9 -	  ++i) {
    6.10 -	i->second=sep;
    6.11 -	vals.push_back(i->first);
    6.12 +      for(typename BaseMap::MapIt i(cref);i!=INVALID; ++i) {
    6.13 +	i.set(sep);
    6.14 +	vals.push_back(i);
    6.15  	sep++;
    6.16        }
    6.17        if(init) sep=0;
    6.18 @@ -303,7 +301,8 @@
    6.19    namespace _iterable_maps_bits {
    6.20      template <typename Item>
    6.21      struct IterableIntMapNode {
    6.22 -      IterableIntMapNode() : value(-1) {}
    6.23 +      IterableIntMapNode() {}
    6.24 +      IterableIntMapNode(int _value) : value(_value) {}
    6.25        Item prev, next;
    6.26        int value;
    6.27      };
    6.28 @@ -313,7 +312,13 @@
    6.29    ///
    6.30    /// \brief Dynamic iterable integer map.
    6.31    ///
    6.32 -  /// \todo Document please
    6.33 +  /// This class provides a special graph map type which can store
    6.34 +  /// for each graph item(node, edge, etc.) an integer value. For each
    6.35 +  /// non negative value it is possible to iterate on the keys which
    6.36 +  /// mapped to the given value.
    6.37 +  /// 
    6.38 +  /// \param _Graph The graph type.
    6.39 +  /// \param _Item One of the graph's item type, the key of the map.
    6.40    template <typename _Graph, typename _Item>
    6.41    class IterableIntMap : protected ItemSetTraits<_Graph, _Item> 
    6.42    ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >::Parent {
    6.43 @@ -322,11 +327,30 @@
    6.44      ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >
    6.45      ::Parent Parent;
    6.46  
    6.47 +    /// The key type
    6.48      typedef _Item Key;
    6.49 +    /// The value type
    6.50      typedef int Value;
    6.51 +    /// The graph type
    6.52      typedef _Graph Graph;
    6.53  
    6.54 -    explicit IterableIntMap(const Graph& graph) : Parent(graph) {}
    6.55 +    /// \brief Constructor of the Map.
    6.56 +    ///
    6.57 +    /// Constructor of the Map. It set all values -1.
    6.58 +    explicit IterableIntMap(const Graph& graph) 
    6.59 +      : Parent(graph, _iterable_maps_bits::IterableIntMapNode<_Item>(-1)) {}
    6.60 +
    6.61 +    /// \brief Constructor of the Map with a given value.
    6.62 +    ///
    6.63 +    /// Constructor of the Map with a given value.
    6.64 +    explicit IterableIntMap(const Graph& graph, int value) 
    6.65 +      : Parent(graph, _iterable_maps_bits::IterableIntMapNode<_Item>(value)) {
    6.66 +      if (value >= 0) {
    6.67 +	for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
    6.68 +	  lace(it);
    6.69 +	}
    6.70 +      }
    6.71 +    }
    6.72  
    6.73    private:
    6.74      
    6.75 @@ -362,8 +386,13 @@
    6.76  
    6.77    public:
    6.78  
    6.79 +    /// Indicates that the map if reference map.
    6.80      typedef True ReferenceMapTag;
    6.81  
    6.82 +    /// \brief Refernce to the value of the map.
    6.83 +    ///
    6.84 +    /// This class is near to similar to the int type. It can
    6.85 +    /// be converted to int and it has the same operators.
    6.86      class Reference {
    6.87        friend class IterableIntMap;
    6.88      private:
    6.89 @@ -447,33 +476,63 @@
    6.90        Key _key;
    6.91        IterableIntMap& _map; 
    6.92      };
    6.93 -    
    6.94 +
    6.95 +    /// The const reference type.    
    6.96      typedef const Value& ConstReference;
    6.97  
    6.98 +    /// \brief Gives back the maximal value plus one.
    6.99 +    ///
   6.100 +    /// Gives back the maximal value plus one.
   6.101      int size() const {
   6.102        return (int)first.size();
   6.103      }
   6.104      
   6.105 +    /// \brief Set operation of the map.
   6.106 +    ///
   6.107 +    /// Set operation of the map.
   6.108      void set(const Key& key, const Value& value) {
   6.109        unlace(key);
   6.110        Parent::operator[](key).value = value;
   6.111        lace(key);
   6.112      }
   6.113  
   6.114 +    /// \brief Const subscript operator of the map.
   6.115 +    ///
   6.116 +    /// Const subscript operator of the map.
   6.117      const Value& operator[](const Key& key) const {
   6.118        return Parent::operator[](key).value;
   6.119      }
   6.120  
   6.121 +    /// \brief Subscript operator of the map.
   6.122 +    ///
   6.123 +    /// Subscript operator of the map.
   6.124      Reference operator[](const Key& key) {
   6.125        return Reference(*this, key);
   6.126      }
   6.127  
   6.128 +    /// \brief Iterator for the keys with the same value.
   6.129 +    ///
   6.130 +    /// Iterator for the keys with the same value. It works
   6.131 +    /// like a graph item iterator in the map, it can be converted
   6.132 +    /// the item type of the map, incremented with \c ++ operator, and
   6.133 +    /// if the iterator leave the last valid item it will be equal to 
   6.134 +    /// \c INVALID.
   6.135      class ItemIt : public _Item {
   6.136      public:
   6.137        typedef _Item Parent;
   6.138  
   6.139 +      /// \brief Invalid constructor \& conversion.
   6.140 +      ///
   6.141 +      /// This constructor initializes the item to be invalid.
   6.142 +      /// \sa Invalid for more details.
   6.143        ItemIt(Invalid) : Parent(INVALID), _map(0) {}
   6.144  
   6.145 +      /// \brief Creates an iterator with a value.
   6.146 +      ///
   6.147 +      /// Creates an iterator with a value. It iterates on the 
   6.148 +      /// keys which have the given value.
   6.149 +      /// \param map The IterableIntMap
   6.150 +      /// \param value The value
   6.151        ItemIt(const IterableIntMap& map, int value) : _map(&map) {
   6.152  	if (value < 0 || value >= (int)_map->first.size()) {	  
   6.153  	  Parent::operator=(INVALID);
   6.154 @@ -482,6 +541,9 @@
   6.155  	}
   6.156        } 
   6.157  
   6.158 +      /// \brief Increment operator.
   6.159 +      ///
   6.160 +      /// Increment Operator.
   6.161        ItemIt& operator++() {
   6.162  	Parent::operator=(_map->IterableIntMap::Parent::
   6.163  			  operator[](static_cast<Parent&>(*this)).next);
     7.1 --- a/lemon/lp_base.h	Wed Nov 16 14:46:22 2005 +0000
     7.2 +++ b/lemon/lp_base.h	Wed Nov 16 18:58:10 2005 +0000
     7.3 @@ -681,16 +681,13 @@
     7.4        return s;
     7.5      }
     7.6      template<class T>
     7.7 -    typename enable_if<typename T::ValueSet::value_type::LpSolverCol,
     7.8 +    typename enable_if<typename T::MapIt::Value::LpSolverCol,
     7.9  		       int>::type
    7.10      addColSet(T &t,dummy<2> = 2) { 
    7.11 -      ///\bug <tt>return addColSet(t.valueSet());</tt> should also work.
    7.12        int s=0;
    7.13 -      for(typename T::ValueSet::iterator i=t.valueSet().begin();
    7.14 -	  i!=t.valueSet().end();
    7.15 -	  ++i)
    7.16 +      for(typename T::MapIt i(t); i!=INVALID; ++i)
    7.17  	{
    7.18 -	  *i=addCol();
    7.19 +	  i.set(addCol());
    7.20  	  s++;
    7.21  	}
    7.22        return s;
    7.23 @@ -787,16 +784,13 @@
    7.24        return s;
    7.25      }
    7.26      template<class T>
    7.27 -    typename enable_if<typename T::ValueSet::value_type::LpSolverRow,
    7.28 +    typename enable_if<typename T::MapIt::Value::LpSolverRow,
    7.29  		       int>::type
    7.30      addRowSet(T &t,dummy<2> = 2) { 
    7.31 -      ///\bug <tt>return addRowSet(t.valueSet());</tt> should also work.
    7.32        int s=0;
    7.33 -      for(typename T::ValueSet::iterator i=t.valueSet().begin();
    7.34 -	  i!=t.valueSet().end();
    7.35 -	  ++i)
    7.36 +      for(typename T::MapIt i(t); i!=INVALID; ++i)
    7.37  	{
    7.38 -	  *i=addRow();
    7.39 +	  i.set(addRow());
    7.40  	  s++;
    7.41  	}
    7.42        return s;
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/lemon/map_iterator.h	Wed Nov 16 18:58:10 2005 +0000
     8.3 @@ -0,0 +1,145 @@
     8.4 +/* -*- C++ -*-
     8.5 + * lemon/map_iterator.h - Part of LEMON, a generic C++ optimization library
     8.6 + *
     8.7 + * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     8.8 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8.9 + *
    8.10 + * Permission to use, modify and distribute this software is granted
    8.11 + * provided that this copyright notice appears in all copies. For
    8.12 + * precise terms see the accompanying LICENSE file.
    8.13 + *
    8.14 + * This software is provided "AS IS" with no warranty of any kind,
    8.15 + * express or implied, and with no claim as to its suitability for any
    8.16 + * purpose.
    8.17 + *
    8.18 + */
    8.19 +
    8.20 +#ifndef LEMON_MAP_ITERATOR_H
    8.21 +#define LEMON_MAP_ITERATOR_H
    8.22 +
    8.23 +#include <lemon/traits.h>
    8.24 +#include <lemon/utility.h>
    8.25 +
    8.26 +/// \ingroup gutils
    8.27 +/// \file
    8.28 +/// \brief Iterators on the maps.
    8.29 +
    8.30 +namespace lemon {
    8.31 +
    8.32 +  /// \ingroup gutils
    8.33 +  ///
    8.34 +  /// \brief Iterator for maps with possibility of changing values.
    8.35 +  ///
    8.36 +  /// Iterator for maps with possibility of changing values.
    8.37 +  template <typename Graph, typename Item, typename Map>
    8.38 +  class MapIt : public ItemSetTraits<Graph, Item>::ItemIt {
    8.39 +  public:
    8.40 +      
    8.41 +    typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
    8.42 +    
    8.43 +    typedef typename Map::Value Value;
    8.44 +    
    8.45 +    /// \brief Creates an iterator
    8.46 +    ///
    8.47 +    /// Creates an iterator for the map, which iterates on the
    8.48 +    /// given graph item set.
    8.49 +    MapIt(const Graph& _graph, Map& _map) : Parent(_graph), map(_map) {}
    8.50 +
    8.51 +    /// \brief Gives back the map's value on the current position.
    8.52 +    ///
    8.53 +    /// Gives back the map's value on the current position.
    8.54 +    typename MapTraits<Map>::ConstReturnValue operator*() const {
    8.55 +      return map[*this];
    8.56 +    }
    8.57 +
    8.58 +    /// \brief Gives back a reference to the map's value.
    8.59 +    ///
    8.60 +    /// Gives back a reference to the map's value on the current position.
    8.61 +    typename MapTraits<Map>::ReturnValue operator*() {
    8.62 +      return map[*this];
    8.63 +    }
    8.64 +    
    8.65 +    /// \brief Sets the value on the current position
    8.66 +    ///
    8.67 +    /// Sets the value on the current position.
    8.68 +    void set(const Value& value) {
    8.69 +      map.set(*this, value);
    8.70 +    }
    8.71 +    
    8.72 +  protected:
    8.73 +    Map& map;
    8.74 +      
    8.75 +  };
    8.76 +
    8.77 +  /// \ingroup gutils
    8.78 +  ///
    8.79 +  /// \brief Iterator for maps with possibility of getting values.
    8.80 +  ///
    8.81 +  /// Iterator for maps with possibility of getting values.
    8.82 +  template <typename Graph, typename Item, typename Map>
    8.83 +  class ConstMapIt : public ItemSetTraits<Graph, Item>::ItemIt {
    8.84 +  public:
    8.85 +    
    8.86 +    typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
    8.87 +
    8.88 +    typedef typename Map::Value Value;
    8.89 +    
    8.90 +    /// \brief Creates an iterator
    8.91 +    ///
    8.92 +    /// Creates an iterator for the map, which iterates on the
    8.93 +    /// given graph item set.
    8.94 +    ConstMapIt(const Graph& _graph, const Map& _map) 
    8.95 +      : Parent(_graph), map(_map) {}
    8.96 +    
    8.97 +    /// \brief Gives back the map's value on the current position.
    8.98 +    ///
    8.99 +    /// Gives back the map's value on the current position.
   8.100 +    typename MapTraits<Map>::ConstReturnValue operator*() const {
   8.101 +      return map[*this];
   8.102 +    }
   8.103 +    
   8.104 +  protected:
   8.105 +    const Map& map;
   8.106 +  };
   8.107 +
   8.108 +
   8.109 +  /// \ingroup gutils
   8.110 +  ///
   8.111 +  /// \brief Iterator for maps which filters items by the values.
   8.112 +  ///
   8.113 +  /// Iterator for maps which gives back only that items which mapped
   8.114 +  /// to an given value.
   8.115 +  template <typename Graph, typename Item, typename Map>
   8.116 +  class FilterMapIt 
   8.117 +    : public ItemSetTraits<Graph, Item>::ItemIt {
   8.118 +  public:
   8.119 +    
   8.120 +    typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
   8.121 +
   8.122 +    typedef typename Map::Value Value;
   8.123 +    
   8.124 +    /// \brief Creates an iterator
   8.125 +    ///
   8.126 +    /// Creates an iterator for the map, which iterates on the
   8.127 +    /// given graph item set and filters all items which mapped value
   8.128 +    /// differ from \c _value.
   8.129 +    FilterMapIt(const Graph& _graph, const Map& _map, const Value& _value) 
   8.130 +      : Parent(_graph), map(_map), value(_value) {}
   8.131 +    
   8.132 +    /// \brief Increment operator
   8.133 +    ///
   8.134 +    /// Skips items which has not the given value.
   8.135 +    FilterMapIt& operator++() {
   8.136 +      Parent::operator++();
   8.137 +      while (*this != INVALID && map[*this] != value) Parent::operator++();
   8.138 +    }
   8.139 +    
   8.140 +  protected:
   8.141 +    const Map& map;
   8.142 +    Value value;
   8.143 +  };
   8.144 +
   8.145 +  
   8.146 +}
   8.147 +
   8.148 +#endif