COIN-OR::LEMON - Graph Library

source: lemon-0.x/lemon/bits/default_map.h @ 2552:5f711e4668f5

Last change on this file since 2552:5f711e4668f5 was 2391:14a343be7a5a, checked in by Alpar Juttner, 17 years ago

Happy New Year to all source files!

File size: 4.7 KB
RevLine 
[906]1/* -*- C++ -*-
2 *
[1956]3 * This file is a part of LEMON, a generic C++ optimization library
4 *
[2391]5 * Copyright (C) 2003-2007
[1956]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>
[2202]25#include <lemon/bits/debug_map.h>
[822]26
[1996]27///\ingroup graphbits
[822]28///\file
[1999]29///\brief Graph maps that construct and destruct their elements dynamically.
[822]30
[921]31namespace lemon {
[1966]32 
[1979]33 
[2333]34#ifndef LEMON_USE_DEBUG_MAP
[822]35
[1966]36  template <typename _Graph, typename _Item, typename _Value>
37  struct DefaultMapSelector {
38    typedef ArrayMap<_Graph, _Item, _Value> Map;
39  };
40
[946]41  // bool
[1267]42  template <typename _Graph, typename _Item>
43  struct DefaultMapSelector<_Graph, _Item, bool> {
[980]44    typedef VectorMap<_Graph, _Item, bool> Map;
[946]45  };
[822]46
[946]47  // char
[1267]48  template <typename _Graph, typename _Item>
49  struct DefaultMapSelector<_Graph, _Item, char> {
[980]50    typedef VectorMap<_Graph, _Item, char> Map;
[946]51  };
[822]52
[1267]53  template <typename _Graph, typename _Item>
54  struct DefaultMapSelector<_Graph, _Item, signed char> {
[980]55    typedef VectorMap<_Graph, _Item, signed char> Map;
[946]56  };
[822]57
[1267]58  template <typename _Graph, typename _Item>
59  struct DefaultMapSelector<_Graph, _Item, unsigned char> {
[980]60    typedef VectorMap<_Graph, _Item, unsigned char> Map;
[946]61  };
[822]62
63
[946]64  // int
[1267]65  template <typename _Graph, typename _Item>
66  struct DefaultMapSelector<_Graph, _Item, signed int> {
[980]67    typedef VectorMap<_Graph, _Item, signed int> Map;
[946]68  };
[822]69
[1267]70  template <typename _Graph, typename _Item>
71  struct DefaultMapSelector<_Graph, _Item, unsigned int> {
[980]72    typedef VectorMap<_Graph, _Item, unsigned int> Map;
[946]73  };
[822]74
75
[946]76  // short
[1267]77  template <typename _Graph, typename _Item>
78  struct DefaultMapSelector<_Graph, _Item, signed short> {
[980]79    typedef VectorMap<_Graph, _Item, signed short> Map;
[946]80  };
[822]81
[1267]82  template <typename _Graph, typename _Item>
83  struct DefaultMapSelector<_Graph, _Item, unsigned short> {
[980]84    typedef VectorMap<_Graph, _Item, unsigned short> Map;
[946]85  };
86
87
88  // long
[1267]89  template <typename _Graph, typename _Item>
90  struct DefaultMapSelector<_Graph, _Item, signed long> {
[980]91    typedef VectorMap<_Graph, _Item, signed long> Map;
[946]92  };
93
[1267]94  template <typename _Graph, typename _Item>
95  struct DefaultMapSelector<_Graph, _Item, unsigned long> {
[980]96    typedef VectorMap<_Graph, _Item, unsigned long> Map;
[946]97  };
98
[1965]99
[2164]100#if defined __GNUC__ && !defined __STRICT_ANSI__
[1965]101
102  // long long
103  template <typename _Graph, typename _Item>
104  struct DefaultMapSelector<_Graph, _Item, signed long long> {
105    typedef VectorMap<_Graph, _Item, signed long long> Map;
106  };
107
108  template <typename _Graph, typename _Item>
109  struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
110    typedef VectorMap<_Graph, _Item, unsigned long long> Map;
111  };
112
113#endif
[946]114
115
116  // float
[1267]117  template <typename _Graph, typename _Item>
118  struct DefaultMapSelector<_Graph, _Item, float> {
[980]119    typedef VectorMap<_Graph, _Item, float> Map;
[946]120  };
121
122
123  // double
[1267]124  template <typename _Graph, typename _Item>
125  struct DefaultMapSelector<_Graph, _Item, double> {
[980]126    typedef VectorMap<_Graph, _Item,  double> Map;
[946]127  };
128
129
130  // long double
[1267]131  template <typename _Graph, typename _Item>
132  struct DefaultMapSelector<_Graph, _Item, long double> {
[980]133    typedef VectorMap<_Graph, _Item, long double> Map;
[946]134  };
135
136
137  // pointer
[1267]138  template <typename _Graph, typename _Item, typename _Ptr>
139  struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
[980]140    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
[946]141  };
142
[2202]143#else
144
145  template <typename _Graph, typename _Item, typename _Value>
146  struct DefaultMapSelector {
147    typedef DebugMap<_Graph, _Item, _Value> Map;
148  };
149
150#endif 
151
[1669]152  /// \e
[1999]153  template <typename _Graph, typename _Item, typename _Value>
[1267]154  class DefaultMap
155    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
[946]156  public:
[1267]157    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
158    typedef DefaultMap<_Graph, _Item, _Value> Map;
[946]159   
160    typedef typename Parent::Graph Graph;
[987]161    typedef typename Parent::Value Value;
[946]162
[2046]163    explicit DefaultMap(const Graph& graph) : Parent(graph) {}
[1999]164    DefaultMap(const Graph& graph, const Value& value)
165      : Parent(graph, value) {}
[1669]166
[2031]167    DefaultMap& operator=(const DefaultMap& cmap) {
168      return operator=<DefaultMap>(cmap);
169    }
170
171    template <typename CMap>
172    DefaultMap& operator=(const CMap& cmap) {
173      Parent::operator=(cmap);
174      return *this;
175    }
176
[946]177  };
178
[822]179}
180
181#endif
Note: See TracBrowser for help on using the repository browser.