00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LEMON_MAP_ITERATOR_H
00020 #define LEMON_MAP_ITERATOR_H
00021
00022 #include <lemon/traits.h>
00023 #include <lemon/utility.h>
00024
00028
00029 namespace lemon {
00030
00036 template <typename Graph, typename Item, typename Map>
00037 class MapIt : public ItemSetTraits<Graph, Item>::ItemIt {
00038 public:
00039
00040 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
00041
00042 typedef typename Map::Value Value;
00043
00048 MapIt(const Graph& _graph, Map& _map) : Parent(_graph), map(_map) {}
00049
00053 typename MapTraits<Map>::ConstReturnValue operator*() const {
00054 return map[*this];
00055 }
00056
00060 typename MapTraits<Map>::ReturnValue operator*() {
00061 return map[*this];
00062 }
00063
00067 void set(const Value& value) {
00068 map.set(*this, value);
00069 }
00070
00071 protected:
00072 Map& map;
00073
00074 };
00075
00081 template <typename Graph, typename Item, typename Map>
00082 class ConstMapIt : public ItemSetTraits<Graph, Item>::ItemIt {
00083 public:
00084
00085 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
00086
00087 typedef typename Map::Value Value;
00088
00093 ConstMapIt(const Graph& _graph, const Map& _map)
00094 : Parent(_graph), map(_map) {}
00095
00099 typename MapTraits<Map>::ConstReturnValue operator*() const {
00100 return map[*this];
00101 }
00102
00103 protected:
00104 const Map& map;
00105 };
00106
00107
00114 template <typename Graph, typename Item, typename Map>
00115 class FilterMapIt
00116 : public ItemSetTraits<Graph, Item>::ItemIt {
00117 public:
00118
00119 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
00120
00121 typedef typename Map::Value Value;
00122
00128 FilterMapIt(const Graph& _graph, const Map& _map, const Value& _value)
00129 : Parent(_graph), map(_map), value(_value) {}
00130
00134 FilterMapIt& operator++() {
00135 Parent::operator++();
00136 while (*this != INVALID && map[*this] != value) Parent::operator++();
00137 }
00138
00139 protected:
00140 const Map& map;
00141 Value value;
00142 };
00143
00144
00145 }
00146
00147 #endif