3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_BITS_MAP_EXTENDER_H
20 #define LEMON_BITS_MAP_EXTENDER_H
24 #include <lemon/bits/traits.h>
27 ///\brief Extenders for iterable maps.
31 /// \ingroup graphbits
33 /// \brief Extender for maps
34 template <typename _Map>
35 class MapExtender : public _Map {
39 typedef MapExtender Map;
42 typedef typename Parent::Graph Graph;
43 typedef typename Parent::Key Item;
45 typedef typename Parent::Key Key;
46 typedef typename Parent::Value Value;
52 friend class ConstMapIt;
56 MapExtender(const Graph& graph)
59 MapExtender(const Graph& graph, const Value& value)
60 : Parent(graph, value) {}
63 class MapIt : public Item {
67 typedef typename Map::Value Value;
71 MapIt(Invalid i) : Parent(i) { }
73 explicit MapIt(Map& _map) : map(_map) {
74 map.getNotifier()->first(*this);
77 MapIt(const Map& _map, const Item& item)
78 : Parent(item), map(_map) {}
81 map.getNotifier()->next(*this);
85 typename MapTraits<Map>::ConstReturnValue operator*() const {
89 typename MapTraits<Map>::ReturnValue operator*() {
93 void set(const Value& value) {
94 map.set(*this, value);
102 class ConstMapIt : public Item {
107 typedef typename Map::Value Value;
111 ConstMapIt(Invalid i) : Parent(i) { }
113 explicit ConstMapIt(Map& _map) : map(_map) {
114 map.getNotifier()->first(*this);
117 ConstMapIt(const Map& _map, const Item& item)
118 : Parent(item), map(_map) {}
120 ConstMapIt& operator++() {
121 map.getNotifier()->next(*this);
125 typename MapTraits<Map>::ConstReturnValue operator*() const {
133 class ItemIt : Item {
140 ItemIt(Invalid i) : Parent(i) { }
142 explicit ItemIt(Map& _map) : map(_map) {
143 map->getNotifier()->first(*this);
146 ItemIt(const Map& _map, const Item& item)
147 : Parent(item), map(_map) {}
149 ItemIt& operator++() {
150 map.getNotifier()->next(*this);