[906] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
[1956] | 3 | * This file is a part of LEMON, a generic C++ optimization library |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 2003-2006 |
---|
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
[906] | 8 | * |
---|
| 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. |
---|
| 12 | * |
---|
| 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 |
---|
| 15 | * purpose. |
---|
| 16 | * |
---|
| 17 | */ |
---|
| 18 | |
---|
[1999] | 19 | #ifndef LEMON_BITS_DEFAULT_MAP_H |
---|
| 20 | #define LEMON_BITS_DEFAULT_MAP_H |
---|
[822] | 21 | |
---|
| 22 | |
---|
[1307] | 23 | #include <lemon/bits/array_map.h> |
---|
| 24 | #include <lemon/bits/vector_map.h> |
---|
[822] | 25 | |
---|
[1996] | 26 | ///\ingroup graphbits |
---|
[822] | 27 | ///\file |
---|
[1999] | 28 | ///\brief Graph maps that construct and destruct their elements dynamically. |
---|
[822] | 29 | |
---|
[921] | 30 | namespace lemon { |
---|
[1966] | 31 | |
---|
[1979] | 32 | |
---|
| 33 | #ifndef _GLIBCXX_DEBUG |
---|
[822] | 34 | |
---|
[1966] | 35 | template <typename _Graph, typename _Item, typename _Value> |
---|
| 36 | struct DefaultMapSelector { |
---|
| 37 | typedef ArrayMap<_Graph, _Item, _Value> Map; |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | #else |
---|
[822] | 41 | |
---|
[1267] | 42 | template <typename _Graph, typename _Item, typename _Value> |
---|
[946] | 43 | struct DefaultMapSelector { |
---|
[1965] | 44 | typedef VectorMap<_Graph, _Item, _Value> Map; |
---|
[946] | 45 | }; |
---|
[822] | 46 | |
---|
[1966] | 47 | #endif |
---|
| 48 | |
---|
[946] | 49 | // bool |
---|
[1267] | 50 | template <typename _Graph, typename _Item> |
---|
| 51 | struct DefaultMapSelector<_Graph, _Item, bool> { |
---|
[980] | 52 | typedef VectorMap<_Graph, _Item, bool> Map; |
---|
[946] | 53 | }; |
---|
[822] | 54 | |
---|
[946] | 55 | // char |
---|
[1267] | 56 | template <typename _Graph, typename _Item> |
---|
| 57 | struct DefaultMapSelector<_Graph, _Item, char> { |
---|
[980] | 58 | typedef VectorMap<_Graph, _Item, char> Map; |
---|
[946] | 59 | }; |
---|
[822] | 60 | |
---|
[1267] | 61 | template <typename _Graph, typename _Item> |
---|
| 62 | struct DefaultMapSelector<_Graph, _Item, signed char> { |
---|
[980] | 63 | typedef VectorMap<_Graph, _Item, signed char> Map; |
---|
[946] | 64 | }; |
---|
[822] | 65 | |
---|
[1267] | 66 | template <typename _Graph, typename _Item> |
---|
| 67 | struct DefaultMapSelector<_Graph, _Item, unsigned char> { |
---|
[980] | 68 | typedef VectorMap<_Graph, _Item, unsigned char> Map; |
---|
[946] | 69 | }; |
---|
[822] | 70 | |
---|
| 71 | |
---|
[946] | 72 | // int |
---|
[1267] | 73 | template <typename _Graph, typename _Item> |
---|
| 74 | struct DefaultMapSelector<_Graph, _Item, signed int> { |
---|
[980] | 75 | typedef VectorMap<_Graph, _Item, signed int> Map; |
---|
[946] | 76 | }; |
---|
[822] | 77 | |
---|
[1267] | 78 | template <typename _Graph, typename _Item> |
---|
| 79 | struct DefaultMapSelector<_Graph, _Item, unsigned int> { |
---|
[980] | 80 | typedef VectorMap<_Graph, _Item, unsigned int> Map; |
---|
[946] | 81 | }; |
---|
[822] | 82 | |
---|
| 83 | |
---|
[946] | 84 | // short |
---|
[1267] | 85 | template <typename _Graph, typename _Item> |
---|
| 86 | struct DefaultMapSelector<_Graph, _Item, signed short> { |
---|
[980] | 87 | typedef VectorMap<_Graph, _Item, signed short> Map; |
---|
[946] | 88 | }; |
---|
[822] | 89 | |
---|
[1267] | 90 | template <typename _Graph, typename _Item> |
---|
| 91 | struct DefaultMapSelector<_Graph, _Item, unsigned short> { |
---|
[980] | 92 | typedef VectorMap<_Graph, _Item, unsigned short> Map; |
---|
[946] | 93 | }; |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | // long |
---|
[1267] | 97 | template <typename _Graph, typename _Item> |
---|
| 98 | struct DefaultMapSelector<_Graph, _Item, signed long> { |
---|
[980] | 99 | typedef VectorMap<_Graph, _Item, signed long> Map; |
---|
[946] | 100 | }; |
---|
| 101 | |
---|
[1267] | 102 | template <typename _Graph, typename _Item> |
---|
| 103 | struct DefaultMapSelector<_Graph, _Item, unsigned long> { |
---|
[980] | 104 | typedef VectorMap<_Graph, _Item, unsigned long> Map; |
---|
[946] | 105 | }; |
---|
| 106 | |
---|
[1965] | 107 | |
---|
| 108 | #ifndef __STRICT_ANSI__ |
---|
| 109 | |
---|
| 110 | // long long |
---|
| 111 | template <typename _Graph, typename _Item> |
---|
| 112 | struct DefaultMapSelector<_Graph, _Item, signed long long> { |
---|
| 113 | typedef VectorMap<_Graph, _Item, signed long long> Map; |
---|
| 114 | }; |
---|
| 115 | |
---|
| 116 | template <typename _Graph, typename _Item> |
---|
| 117 | struct DefaultMapSelector<_Graph, _Item, unsigned long long> { |
---|
| 118 | typedef VectorMap<_Graph, _Item, unsigned long long> Map; |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | #endif |
---|
[946] | 122 | |
---|
| 123 | |
---|
| 124 | // float |
---|
[1267] | 125 | template <typename _Graph, typename _Item> |
---|
| 126 | struct DefaultMapSelector<_Graph, _Item, float> { |
---|
[980] | 127 | typedef VectorMap<_Graph, _Item, float> Map; |
---|
[946] | 128 | }; |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | // double |
---|
[1267] | 132 | template <typename _Graph, typename _Item> |
---|
| 133 | struct DefaultMapSelector<_Graph, _Item, double> { |
---|
[980] | 134 | typedef VectorMap<_Graph, _Item, double> Map; |
---|
[946] | 135 | }; |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | // long double |
---|
[1267] | 139 | template <typename _Graph, typename _Item> |
---|
| 140 | struct DefaultMapSelector<_Graph, _Item, long double> { |
---|
[980] | 141 | typedef VectorMap<_Graph, _Item, long double> Map; |
---|
[946] | 142 | }; |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | // pointer |
---|
[1267] | 146 | template <typename _Graph, typename _Item, typename _Ptr> |
---|
| 147 | struct DefaultMapSelector<_Graph, _Item, _Ptr*> { |
---|
[980] | 148 | typedef VectorMap<_Graph, _Item, _Ptr*> Map; |
---|
[946] | 149 | }; |
---|
| 150 | |
---|
[1669] | 151 | /// \e |
---|
[1999] | 152 | template <typename _Graph, typename _Item, typename _Value> |
---|
[1267] | 153 | class DefaultMap |
---|
| 154 | : public DefaultMapSelector<_Graph, _Item, _Value>::Map { |
---|
[946] | 155 | public: |
---|
[1267] | 156 | typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; |
---|
| 157 | typedef DefaultMap<_Graph, _Item, _Value> Map; |
---|
[946] | 158 | |
---|
| 159 | typedef typename Parent::Graph Graph; |
---|
[987] | 160 | typedef typename Parent::Value Value; |
---|
[946] | 161 | |
---|
[1999] | 162 | DefaultMap(const Graph& graph) : Parent(graph) {} |
---|
| 163 | DefaultMap(const Graph& graph, const Value& value) |
---|
| 164 | : Parent(graph, value) {} |
---|
[1669] | 165 | |
---|
[946] | 166 | }; |
---|
| 167 | |
---|
[822] | 168 | } |
---|
| 169 | |
---|
| 170 | #endif |
---|