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
32 template <typename _Map>
33 class IterableMapExtender : public _Map {
37 typedef IterableMapExtender Map;
40 typedef typename Parent::Graph Graph;
41 typedef typename Parent::Key Item;
43 typedef typename Parent::Key Key;
44 typedef typename Parent::Value Value;
50 friend class ConstMapIt;
54 using Parent::getGraph;
58 IterableMapExtender(const Graph& graph) : Parent(graph) {}
60 IterableMapExtender(const Graph& graph, const Value& value)
61 : Parent(graph, value) {}
64 class MapIt : public ItemSetTraits<Graph, Item>::ItemIt {
67 typedef typename ItemSetTraits<Graph, Item>::ItemIt Parent;
69 typedef typename Map::Value Value;
71 MapIt(Map& _map) : Parent(*_map.getGraph()), map(_map) {}
73 typename MapTraits<Map>::ConstReturnValue operator*() const {
77 typename MapTraits<Map>::ReturnValue operator*() {
81 void set(const Value& value) {
82 map.set(*this, value);
90 class ConstMapIt : public ItemSetTraits<Graph, Key>::ItemIt {
93 typedef typename ItemSetTraits<Graph, Key>::ItemIt Parent;
95 typedef typename Map::Value Value;
97 ConstMapIt(const Map& _map) : Parent(*_map.getGraph()), map(_map) {}
99 typename MapTraits<Map>::ConstReturnValue operator*() const {
106 class ItemIt : public ItemSetTraits<Graph, Key>::ItemIt {
109 typedef typename ItemSetTraits<Graph, Key>::ItemIt Parent;
111 ItemIt(Map& _map) : Parent(*_map.getGraph()) {}