Added 'src/demo/Makefile.am'.
2 * src/lemon/default_map.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #ifndef LEMON_DEFAULT_MAP_H
18 #define LEMON_DEFAULT_MAP_H
21 #include <lemon/array_map.h>
22 #include <lemon/vector_map.h>
26 ///\brief Graph maps that construates and destruates
27 ///their elements dynamically.
31 /// \addtogroup graphmaps
34 /** The ArrayMap template class is graph map structure what
35 * automatically updates the map when a key is added to or erased from
36 * the map. This map uses the VectorMap if the ValueType is a primitive
37 * type and the ArrayMap for the other cases.
39 * The template parameter is the MapRegistry that the maps
40 * will belong to and the ValueType.
44 /** Macro to implement the DefaultMap.
46 #define DEFAULT_MAP_BODY(DynMap, Value) \
51 typedef DynMap<MapRegistry, Value> Parent; \
53 typedef typename MapRegistry::Graph Graph; \
55 DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
56 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
57 : Parent(g, r, v) {} \
58 DefaultMap(const DefaultMap& copy) \
59 : Parent(static_cast<const Parent&>(copy)) {} \
60 template <typename TT> \
61 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \
63 Parent::MapBase::operator= \
64 (static_cast<const typename Parent::MapBase&>(copy)); \
65 if (Parent::getGraph()) { \
66 for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
68 Parent::operator[](it) = copy[it]; \
72 DefaultMap& operator=(const DefaultMap& copy) { \
73 Parent::operator=(static_cast<const Parent&>(copy)); \
76 template <typename TT> \
77 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
78 if (Parent::getGraph() != copy.getGraph()) { \
80 Parent::MapBase::operator=(copy); \
81 Parent::construct(); \
83 if (Parent::getGraph()) { \
84 for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
85 Parent::operator[](it) = copy[it]; \
93 template <typename MapRegistry, typename Type>
94 class DefaultMap : public ArrayMap<MapRegistry, Type>
95 DEFAULT_MAP_BODY(ArrayMap, Type);
97 template <typename MapRegistry>
98 class DefaultMap<MapRegistry, bool>
99 : public VectorMap<MapRegistry, bool>
100 DEFAULT_MAP_BODY(VectorMap, bool);
102 template <typename MapRegistry>
103 class DefaultMap<MapRegistry, char>
104 : public VectorMap<MapRegistry, char>
105 DEFAULT_MAP_BODY(VectorMap, char);
107 template <typename MapRegistry>
108 class DefaultMap<MapRegistry, int>
109 : public VectorMap<MapRegistry, int>
110 DEFAULT_MAP_BODY(VectorMap, int);
112 template <typename MapRegistry>
113 class DefaultMap<MapRegistry, short>
114 : public VectorMap<MapRegistry, short>
115 DEFAULT_MAP_BODY(VectorMap, short);
117 template <typename MapRegistry>
118 class DefaultMap<MapRegistry, long>
119 : public VectorMap<MapRegistry, long>
120 DEFAULT_MAP_BODY(VectorMap, long);
122 template <typename MapRegistry>
123 class DefaultMap<MapRegistry, float>
124 : public VectorMap<MapRegistry, float>
125 DEFAULT_MAP_BODY(VectorMap, float);
127 template <typename MapRegistry>
128 class DefaultMap<MapRegistry, double>
129 : public VectorMap<MapRegistry, double>
130 DEFAULT_MAP_BODY(VectorMap, double);
132 template <typename MapRegistry>
133 class DefaultMap<MapRegistry, long double>
134 : public VectorMap<MapRegistry, long double>
135 DEFAULT_MAP_BODY(VectorMap, long double);
137 template <typename MapRegistry, typename Type>
138 class DefaultMap<MapRegistry, Type*>
139 : public VectorMap<MapRegistry, Type*>
140 DEFAULT_MAP_BODY(VectorMap, Type*);