Fight with Doxygen.
Victory hasn't been reached yet, but it's on the horizon.
2 * lemon/map_iterator.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
17 #ifndef LEMON_MAP_ITERATOR_H
18 #define LEMON_MAP_ITERATOR_H
20 #include <lemon/traits.h>
21 #include <lemon/utility.h>
25 /// \brief Iterators on the maps.
31 /// \brief Iterator for maps with possibility of changing values.
33 /// Iterator for maps with possibility of changing values.
34 template <typename Graph, typename Item, typename Map>
35 class MapIt : public ItemSetTraits<Graph, Item>::ItemIt {
38 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
40 typedef typename Map::Value Value;
42 /// \brief Creates an iterator
44 /// Creates an iterator for the map, which iterates on the
45 /// given graph item set.
46 MapIt(const Graph& _graph, Map& _map) : Parent(_graph), map(_map) {}
48 /// \brief Gives back the map's value on the current position.
50 /// Gives back the map's value on the current position.
51 typename MapTraits<Map>::ConstReturnValue operator*() const {
55 /// \brief Gives back a reference to the map's value.
57 /// Gives back a reference to the map's value on the current position.
58 typename MapTraits<Map>::ReturnValue operator*() {
62 /// \brief Sets the value on the current position
64 /// Sets the value on the current position.
65 void set(const Value& value) {
66 map.set(*this, value);
76 /// \brief Iterator for maps with possibility of getting values.
78 /// Iterator for maps with possibility of getting values.
79 template <typename Graph, typename Item, typename Map>
80 class ConstMapIt : public ItemSetTraits<Graph, Item>::ItemIt {
83 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
85 typedef typename Map::Value Value;
87 /// \brief Creates an iterator
89 /// Creates an iterator for the map, which iterates on the
90 /// given graph item set.
91 ConstMapIt(const Graph& _graph, const Map& _map)
92 : Parent(_graph), map(_map) {}
94 /// \brief Gives back the map's value on the current position.
96 /// Gives back the map's value on the current position.
97 typename MapTraits<Map>::ConstReturnValue operator*() const {
108 /// \brief Iterator for maps which filters items by the values.
110 /// Iterator for maps which gives back only that items which mapped
111 /// to an given value.
112 template <typename Graph, typename Item, typename Map>
114 : public ItemSetTraits<Graph, Item>::ItemIt {
117 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
119 typedef typename Map::Value Value;
121 /// \brief Creates an iterator
123 /// Creates an iterator for the map, which iterates on the
124 /// given graph item set and filters all items which mapped value
125 /// differ from \c _value.
126 FilterMapIt(const Graph& _graph, const Map& _map, const Value& _value)
127 : Parent(_graph), map(_map), value(_value) {}
129 /// \brief Increment operator
131 /// Skips items which has not the given value.
132 FilterMapIt& operator++() {
133 Parent::operator++();
134 while (*this != INVALID && map[*this] != value) Parent::operator++();