00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef LEMON_DEFAULT_MAP_H
00018 #define LEMON_DEFAULT_MAP_H
00019
00020
00021 #include <lemon/array_map.h>
00022 #include <lemon/vector_map.h>
00023
00028
00029 namespace lemon {
00030
00033
00045 template <typename _Graph, typename _Item, typename _ItemIt, typename _Value>
00046 struct DefaultMapSelector {
00047 typedef ArrayMap<_Graph, _Item, _ItemIt, _Value> Map;
00048 };
00049
00050
00051 template <typename _Graph, typename _Item, typename _ItemIt>
00052 struct DefaultMapSelector<_Graph, _Item, _ItemIt, bool> {
00053 typedef VectorMap<_Graph, _Item, bool> Map;
00054 };
00055
00056
00057 template <typename _Graph, typename _Item, typename _ItemIt>
00058 struct DefaultMapSelector<_Graph, _Item, _ItemIt, char> {
00059 typedef VectorMap<_Graph, _Item, char> Map;
00060 };
00061
00062 template <typename _Graph, typename _Item, typename _ItemIt>
00063 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed char> {
00064 typedef VectorMap<_Graph, _Item, signed char> Map;
00065 };
00066
00067 template <typename _Graph, typename _Item, typename _ItemIt>
00068 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned char> {
00069 typedef VectorMap<_Graph, _Item, unsigned char> Map;
00070 };
00071
00072
00073
00074 template <typename _Graph, typename _Item, typename _ItemIt>
00075 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed int> {
00076 typedef VectorMap<_Graph, _Item, signed int> Map;
00077 };
00078
00079 template <typename _Graph, typename _Item, typename _ItemIt>
00080 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned int> {
00081 typedef VectorMap<_Graph, _Item, unsigned int> Map;
00082 };
00083
00084
00085
00086 template <typename _Graph, typename _Item, typename _ItemIt>
00087 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed short> {
00088 typedef VectorMap<_Graph, _Item, signed short> Map;
00089 };
00090
00091 template <typename _Graph, typename _Item, typename _ItemIt>
00092 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned short> {
00093 typedef VectorMap<_Graph, _Item, unsigned short> Map;
00094 };
00095
00096
00097
00098 template <typename _Graph, typename _Item, typename _ItemIt>
00099 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed long> {
00100 typedef VectorMap<_Graph, _Item, signed long> Map;
00101 };
00102
00103 template <typename _Graph, typename _Item, typename _ItemIt>
00104 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned long> {
00105 typedef VectorMap<_Graph, _Item, unsigned long> Map;
00106 };
00107
00108
00109
00110
00111
00112 template <typename _Graph, typename _Item, typename _ItemIt>
00113 struct DefaultMapSelector<_Graph, _Item, _ItemIt, float> {
00114 typedef VectorMap<_Graph, _Item, float> Map;
00115 };
00116
00117
00118
00119 template <typename _Graph, typename _Item, typename _ItemIt>
00120 struct DefaultMapSelector<_Graph, _Item, _ItemIt, double> {
00121 typedef VectorMap<_Graph, _Item, double> Map;
00122 };
00123
00124
00125
00126 template <typename _Graph, typename _Item, typename _ItemIt>
00127 struct DefaultMapSelector<_Graph, _Item, _ItemIt, long double> {
00128 typedef VectorMap<_Graph, _Item, long double> Map;
00129 };
00130
00131
00132
00133 template <typename _Graph, typename _Item, typename _ItemIt, typename _Ptr>
00134 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _Ptr*> {
00135 typedef VectorMap<_Graph, _Item, _Ptr*> Map;
00136 };
00137
00138
00139
00140 template <typename _Graph,
00141 typename _Item,
00142 typename _ItemIt,
00143 typename _Value>
00144 class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map {
00145 public:
00146 typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map Parent;
00147 typedef DefaultMap<_Graph, _Item, _ItemIt, _Value> Map;
00148
00149 typedef typename Parent::Graph Graph;
00150 typedef typename Parent::Value Value;
00151
00152 DefaultMap(const Graph& _g) : Parent(_g) {}
00153 DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {}
00154 };
00155
00156
00157
00158 template <typename _Base>
00159 class DefaultMappableGraphExtender : public _Base {
00160 public:
00161
00162 typedef DefaultMappableGraphExtender<_Base> Graph;
00163 typedef _Base Parent;
00164
00165 typedef typename Parent::Node Node;
00166 typedef typename Parent::NodeIt NodeIt;
00167
00168 typedef typename Parent::Edge Edge;
00169 typedef typename Parent::EdgeIt EdgeIt;
00170
00171
00172 template <typename _Value>
00173 class NodeMap : public DefaultMap<Graph, Node, NodeIt, _Value> {
00174 public:
00175 typedef DefaultMappableGraphExtender Graph;
00176 typedef DefaultMap<Graph, Node, NodeIt, _Value> Parent;
00177
00178 NodeMap(const Graph& _g)
00179 : Parent(_g) {}
00180 NodeMap(const Graph& _g, const _Value& _v)
00181 : Parent(_g, _v) {}
00182 };
00183
00184 template <typename _Value>
00185 class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, _Value> {
00186 public:
00187 typedef DefaultMappableGraphExtender Graph;
00188 typedef DefaultMap<Graph, Edge, EdgeIt, _Value> Parent;
00189
00190 EdgeMap(const Graph& _g)
00191 : Parent(_g) {}
00192 EdgeMap(const Graph& _g, const _Value& _v)
00193 : Parent(_g, _v) {}
00194 };
00195
00196 };
00197
00198 template <typename _Base>
00199 class MappableUndirGraphExtender :
00200 public DefaultMappableGraphExtender<_Base> {
00201 public:
00202
00203 typedef MappableUndirGraphExtender Graph;
00204 typedef DefaultMappableGraphExtender<_Base> Parent;
00205
00206 typedef typename Parent::UndirEdge UndirEdge;
00207 typedef typename Parent::UndirEdgeIt UndirEdgeIt;
00208
00209 template <typename _Value>
00210 class UndirEdgeMap :
00211 public DefaultMap<Graph, UndirEdge, UndirEdgeIt, _Value> {
00212 public:
00213 typedef MappableUndirGraphExtender Graph;
00214 typedef DefaultMap<Graph, UndirEdge, UndirEdgeIt, _Value> Parent;
00215
00216 UndirEdgeMap(const Graph& _g)
00217 : Parent(_g) {}
00218 UndirEdgeMap(const Graph& _g, const _Value& _v)
00219 : Parent(_g, _v) {}
00220 };
00221
00222
00223 };
00224
00225 }
00226
00227 #endif