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