1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
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_DEFAULT_MAP_H
20 #define LEMON_BITS_DEFAULT_MAP_H
22 #include <lemon/bits/array_map.h>
23 #include <lemon/bits/vector_map.h>
24 //#include <lemon/bits/debug_map.h>
28 //\brief Graph maps that construct and destruct their elements dynamically.
33 //#ifndef LEMON_USE_DEBUG_MAP
35 template <typename _Graph, typename _Item, typename _Value>
36 struct DefaultMapSelector {
37 typedef ArrayMap<_Graph, _Item, _Value> Map;
41 template <typename _Graph, typename _Item>
42 struct DefaultMapSelector<_Graph, _Item, bool> {
43 typedef VectorMap<_Graph, _Item, bool> Map;
47 template <typename _Graph, typename _Item>
48 struct DefaultMapSelector<_Graph, _Item, char> {
49 typedef VectorMap<_Graph, _Item, char> Map;
52 template <typename _Graph, typename _Item>
53 struct DefaultMapSelector<_Graph, _Item, signed char> {
54 typedef VectorMap<_Graph, _Item, signed char> Map;
57 template <typename _Graph, typename _Item>
58 struct DefaultMapSelector<_Graph, _Item, unsigned char> {
59 typedef VectorMap<_Graph, _Item, unsigned char> Map;
64 template <typename _Graph, typename _Item>
65 struct DefaultMapSelector<_Graph, _Item, signed int> {
66 typedef VectorMap<_Graph, _Item, signed int> Map;
69 template <typename _Graph, typename _Item>
70 struct DefaultMapSelector<_Graph, _Item, unsigned int> {
71 typedef VectorMap<_Graph, _Item, unsigned int> Map;
76 template <typename _Graph, typename _Item>
77 struct DefaultMapSelector<_Graph, _Item, signed short> {
78 typedef VectorMap<_Graph, _Item, signed short> Map;
81 template <typename _Graph, typename _Item>
82 struct DefaultMapSelector<_Graph, _Item, unsigned short> {
83 typedef VectorMap<_Graph, _Item, unsigned short> Map;
88 template <typename _Graph, typename _Item>
89 struct DefaultMapSelector<_Graph, _Item, signed long> {
90 typedef VectorMap<_Graph, _Item, signed long> Map;
93 template <typename _Graph, typename _Item>
94 struct DefaultMapSelector<_Graph, _Item, unsigned long> {
95 typedef VectorMap<_Graph, _Item, unsigned long> Map;
99 #if defined __GNUC__ && !defined __STRICT_ANSI__
102 template <typename _Graph, typename _Item>
103 struct DefaultMapSelector<_Graph, _Item, signed long long> {
104 typedef VectorMap<_Graph, _Item, signed long long> Map;
107 template <typename _Graph, typename _Item>
108 struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
109 typedef VectorMap<_Graph, _Item, unsigned long long> Map;
116 template <typename _Graph, typename _Item>
117 struct DefaultMapSelector<_Graph, _Item, float> {
118 typedef VectorMap<_Graph, _Item, float> Map;
123 template <typename _Graph, typename _Item>
124 struct DefaultMapSelector<_Graph, _Item, double> {
125 typedef VectorMap<_Graph, _Item, double> Map;
130 template <typename _Graph, typename _Item>
131 struct DefaultMapSelector<_Graph, _Item, long double> {
132 typedef VectorMap<_Graph, _Item, long double> Map;
137 template <typename _Graph, typename _Item, typename _Ptr>
138 struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
139 typedef VectorMap<_Graph, _Item, _Ptr*> Map;
144 // template <typename _Graph, typename _Item, typename _Value>
145 // struct DefaultMapSelector {
146 // typedef DebugMap<_Graph, _Item, _Value> Map;
152 template <typename _Graph, typename _Item, typename _Value>
154 : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
156 typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
157 typedef DefaultMap<_Graph, _Item, _Value> Map;
159 typedef typename Parent::Graph Graph;
160 typedef typename Parent::Value Value;
162 explicit DefaultMap(const Graph& graph) : Parent(graph) {}
163 DefaultMap(const Graph& graph, const Value& value)
164 : Parent(graph, value) {}
166 DefaultMap& operator=(const DefaultMap& cmap) {
167 return operator=<DefaultMap>(cmap);
170 template <typename CMap>
171 DefaultMap& operator=(const CMap& cmap) {
172 Parent::operator=(cmap);