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/traits.h>
27 ///\brief Extenders for iterable maps.
31 template <typename _Map>
32 class IterableMapExtender : public _Map {
36 typedef IterableMapExtender Map;
39 typedef typename Parent::Graph Graph;
40 typedef typename Parent::Key Item;
42 typedef typename Parent::Key Key;
43 typedef typename Parent::Value Value;
49 friend class ConstMapIt;
53 using Parent::getGraph;
57 IterableMapExtender(const Graph& graph) : Parent(graph) {}
59 IterableMapExtender(const Graph& graph, const Value& value)
60 : Parent(graph, value) {}
63 class MapIt : public ItemSetTraits<Graph, Item>::ItemIt {
66 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
68 typedef typename Map::Value Value;
70 MapIt(Map& _map) : Parent(*_map.getGraph()), map(_map) {}
72 typename MapTraits<Map>::ConstReturnValue operator*() const {
76 typename MapTraits<Map>::ReturnValue operator*() {
80 void set(const Value& value) {
81 map.set(*this, value);
89 class ConstMapIt : public ItemSetTraits<Graph, Key>::ItemIt {
92 typedef typename ItemSetTraits<Graph, Key>::ItemIt Parent;
94 typedef typename Map::Value Value;
96 ConstMapIt(const Map& _map) : Parent(*_map.getGraph()), map(_map) {}
98 typename MapTraits<Map>::ConstReturnValue operator*() const {
105 class ItemIt : public ItemSetTraits<Graph, Key>::ItemIt {
108 typedef typename ItemSetTraits<Graph, Key>::ItemIt Parent;
110 ItemIt(Map& _map) : Parent(*_map.getGraph()) {}