Update INSTALL to use CMAKE. Also update AUTHORS and LICENSE
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2009
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>
26 #include <lemon/concept_check.h>
27 #include <lemon/concepts/maps.h>
30 //\brief Extenders for iterable maps.
36 // \brief Extender for maps
37 template <typename _Map>
38 class MapExtender : public _Map {
40 typedef typename Parent::GraphType GraphType;
44 typedef MapExtender Map;
45 typedef typename Parent::Key Item;
47 typedef typename Parent::Key Key;
48 typedef typename Parent::Value Value;
49 typedef typename Parent::Reference Reference;
50 typedef typename Parent::ConstReference ConstReference;
52 typedef typename Parent::ReferenceMapTag ReferenceMapTag;
58 friend class ConstMapIt;
62 MapExtender(const GraphType& graph)
65 MapExtender(const GraphType& graph, const Value& value)
66 : Parent(graph, value) {}
69 MapExtender& operator=(const MapExtender& cmap) {
70 return operator=<MapExtender>(cmap);
73 template <typename CMap>
74 MapExtender& operator=(const CMap& cmap) {
75 Parent::operator=(cmap);
80 class MapIt : public Item {
85 typedef typename Map::Value Value;
87 MapIt() : map(NULL) {}
89 MapIt(Invalid i) : Parent(i), map(NULL) {}
91 explicit MapIt(Map& _map) : map(&_map) {
92 map->notifier()->first(*this);
95 MapIt(const Map& _map, const Item& item)
96 : Parent(item), map(&_map) {}
99 map->notifier()->next(*this);
103 typename MapTraits<Map>::ConstReturnValue operator*() const {
104 return (*map)[*this];
107 typename MapTraits<Map>::ReturnValue operator*() {
108 return (*map)[*this];
111 void set(const Value& value) {
112 map->set(*this, value);
120 class ConstMapIt : public Item {
125 typedef typename Map::Value Value;
127 ConstMapIt() : map(NULL) {}
129 ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
131 explicit ConstMapIt(Map& _map) : map(&_map) {
132 map->notifier()->first(*this);
135 ConstMapIt(const Map& _map, const Item& item)
136 : Parent(item), map(_map) {}
138 ConstMapIt& operator++() {
139 map->notifier()->next(*this);
143 typename MapTraits<Map>::ConstReturnValue operator*() const {
151 class ItemIt : public Item {
155 ItemIt() : map(NULL) {}
158 ItemIt(Invalid i) : Parent(i), map(NULL) {}
160 explicit ItemIt(Map& _map) : map(&_map) {
161 map->notifier()->first(*this);
164 ItemIt(const Map& _map, const Item& item)
165 : Parent(item), map(&_map) {}
167 ItemIt& operator++() {
168 map->notifier()->next(*this);
178 // \ingroup graphbits
180 // \brief Extender for maps which use a subset of the items.
181 template <typename _Graph, typename _Map>
182 class SubMapExtender : public _Map {
184 typedef _Graph GraphType;
188 typedef SubMapExtender Map;
189 typedef typename Parent::Key Item;
191 typedef typename Parent::Key Key;
192 typedef typename Parent::Value Value;
193 typedef typename Parent::Reference Reference;
194 typedef typename Parent::ConstReference ConstReference;
196 typedef typename Parent::ReferenceMapTag ReferenceMapTag;
202 friend class ConstMapIt;
206 SubMapExtender(const GraphType& _graph)
207 : Parent(_graph), graph(_graph) {}
209 SubMapExtender(const GraphType& _graph, const Value& _value)
210 : Parent(_graph, _value), graph(_graph) {}
213 SubMapExtender& operator=(const SubMapExtender& cmap) {
214 return operator=<MapExtender>(cmap);
217 template <typename CMap>
218 SubMapExtender& operator=(const CMap& cmap) {
219 checkConcept<concepts::ReadMap<Key, Value>, CMap>();
221 for (graph.first(it); it != INVALID; graph.next(it)) {
222 Parent::set(it, cmap[it]);
228 class MapIt : public Item {
232 typedef typename Map::Value Value;
234 MapIt() : map(NULL) {}
236 MapIt(Invalid i) : Parent(i), map(NULL) { }
238 explicit MapIt(Map& _map) : map(&_map) {
239 map->graph.first(*this);
242 MapIt(const Map& _map, const Item& item)
243 : Parent(item), map(&_map) {}
245 MapIt& operator++() {
246 map->graph.next(*this);
250 typename MapTraits<Map>::ConstReturnValue operator*() const {
251 return (*map)[*this];
254 typename MapTraits<Map>::ReturnValue operator*() {
255 return (*map)[*this];
258 void set(const Value& value) {
259 map->set(*this, value);
267 class ConstMapIt : public Item {
272 typedef typename Map::Value Value;
274 ConstMapIt() : map(NULL) {}
276 ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
278 explicit ConstMapIt(Map& _map) : map(&_map) {
279 map->graph.first(*this);
282 ConstMapIt(const Map& _map, const Item& item)
283 : Parent(item), map(&_map) {}
285 ConstMapIt& operator++() {
286 map->graph.next(*this);
290 typename MapTraits<Map>::ConstReturnValue operator*() const {
291 return (*map)[*this];
298 class ItemIt : public Item {
302 ItemIt() : map(NULL) {}
305 ItemIt(Invalid i) : Parent(i), map(NULL) { }
307 explicit ItemIt(Map& _map) : map(&_map) {
308 map->graph.first(*this);
311 ItemIt(const Map& _map, const Item& item)
312 : Parent(item), map(&_map) {}
314 ItemIt& operator++() {
315 map->graph.next(*this);
326 const GraphType& graph;