1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_DEFAULT_MAP_H |
20 | 20 |
#define LEMON_BITS_DEFAULT_MAP_H |
21 | 21 |
|
22 |
#include <lemon/config.h> |
|
22 | 23 |
#include <lemon/bits/array_map.h> |
23 | 24 |
#include <lemon/bits/vector_map.h> |
24 | 25 |
//#include <lemon/bits/debug_map.h> |
25 | 26 |
|
26 | 27 |
//\ingroup graphbits |
27 | 28 |
//\file |
28 | 29 |
//\brief Graph maps that construct and destruct their elements dynamically. |
29 | 30 |
|
30 | 31 |
namespace lemon { |
31 | 32 |
|
32 | 33 |
|
33 | 34 |
//#ifndef LEMON_USE_DEBUG_MAP |
34 | 35 |
|
35 | 36 |
template <typename _Graph, typename _Item, typename _Value> |
36 | 37 |
struct DefaultMapSelector { |
37 | 38 |
typedef ArrayMap<_Graph, _Item, _Value> Map; |
38 | 39 |
}; |
39 | 40 |
|
40 | 41 |
// bool |
41 | 42 |
template <typename _Graph, typename _Item> |
42 | 43 |
struct DefaultMapSelector<_Graph, _Item, bool> { |
43 | 44 |
typedef VectorMap<_Graph, _Item, bool> Map; |
44 | 45 |
}; |
45 | 46 |
|
46 | 47 |
// char |
47 | 48 |
template <typename _Graph, typename _Item> |
48 | 49 |
struct DefaultMapSelector<_Graph, _Item, char> { |
49 | 50 |
typedef VectorMap<_Graph, _Item, char> Map; |
50 | 51 |
}; |
51 | 52 |
|
52 | 53 |
template <typename _Graph, typename _Item> |
53 | 54 |
struct DefaultMapSelector<_Graph, _Item, signed char> { |
54 | 55 |
typedef VectorMap<_Graph, _Item, signed char> Map; |
55 | 56 |
}; |
56 | 57 |
|
57 | 58 |
template <typename _Graph, typename _Item> |
58 | 59 |
struct DefaultMapSelector<_Graph, _Item, unsigned char> { |
59 | 60 |
typedef VectorMap<_Graph, _Item, unsigned char> Map; |
60 | 61 |
}; |
61 | 62 |
|
62 | 63 |
|
63 | 64 |
// int |
64 | 65 |
template <typename _Graph, typename _Item> |
65 | 66 |
struct DefaultMapSelector<_Graph, _Item, signed int> { |
66 | 67 |
typedef VectorMap<_Graph, _Item, signed int> Map; |
67 | 68 |
}; |
68 | 69 |
|
69 | 70 |
template <typename _Graph, typename _Item> |
70 | 71 |
struct DefaultMapSelector<_Graph, _Item, unsigned int> { |
71 | 72 |
typedef VectorMap<_Graph, _Item, unsigned int> Map; |
72 | 73 |
}; |
73 | 74 |
|
74 | 75 |
|
75 | 76 |
// short |
76 | 77 |
template <typename _Graph, typename _Item> |
77 | 78 |
struct DefaultMapSelector<_Graph, _Item, signed short> { |
78 | 79 |
typedef VectorMap<_Graph, _Item, signed short> Map; |
79 | 80 |
}; |
80 | 81 |
|
81 | 82 |
template <typename _Graph, typename _Item> |
82 | 83 |
struct DefaultMapSelector<_Graph, _Item, unsigned short> { |
83 | 84 |
typedef VectorMap<_Graph, _Item, unsigned short> Map; |
84 | 85 |
}; |
85 | 86 |
|
86 | 87 |
|
87 | 88 |
// long |
88 | 89 |
template <typename _Graph, typename _Item> |
89 | 90 |
struct DefaultMapSelector<_Graph, _Item, signed long> { |
90 | 91 |
typedef VectorMap<_Graph, _Item, signed long> Map; |
91 | 92 |
}; |
92 | 93 |
|
93 | 94 |
template <typename _Graph, typename _Item> |
94 | 95 |
struct DefaultMapSelector<_Graph, _Item, unsigned long> { |
95 | 96 |
typedef VectorMap<_Graph, _Item, unsigned long> Map; |
96 | 97 |
}; |
97 | 98 |
|
98 | 99 |
|
99 | 100 |
#if defined HAVE_LONG_LONG |
100 | 101 |
|
101 | 102 |
// long long |
102 | 103 |
template <typename _Graph, typename _Item> |
103 | 104 |
struct DefaultMapSelector<_Graph, _Item, signed long long> { |
104 | 105 |
typedef VectorMap<_Graph, _Item, signed long long> Map; |
105 | 106 |
}; |
106 | 107 |
|
107 | 108 |
template <typename _Graph, typename _Item> |
108 | 109 |
struct DefaultMapSelector<_Graph, _Item, unsigned long long> { |
109 | 110 |
typedef VectorMap<_Graph, _Item, unsigned long long> Map; |
110 | 111 |
}; |
111 | 112 |
|
112 | 113 |
#endif |
113 | 114 |
|
114 | 115 |
|
115 | 116 |
// float |
116 | 117 |
template <typename _Graph, typename _Item> |
117 | 118 |
struct DefaultMapSelector<_Graph, _Item, float> { |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_CORE_H |
20 | 20 |
#define LEMON_CORE_H |
21 | 21 |
|
22 | 22 |
#include <vector> |
23 | 23 |
#include <algorithm> |
24 | 24 |
|
25 |
#include <lemon/core.h> |
|
25 | 26 |
#include <lemon/bits/enable_if.h> |
26 | 27 |
#include <lemon/bits/traits.h> |
27 | 28 |
#include <lemon/assert.h> |
28 | 29 |
|
29 | 30 |
///\file |
30 | 31 |
///\brief LEMON core utilities. |
31 | 32 |
/// |
32 | 33 |
///This header file contains core utilities for LEMON. |
33 | 34 |
///It is automatically included by all graph types, therefore it usually |
34 | 35 |
///do not have to be included directly. |
35 | 36 |
|
36 | 37 |
namespace lemon { |
37 | 38 |
|
38 | 39 |
/// \brief Dummy type to make it easier to create invalid iterators. |
39 | 40 |
/// |
40 | 41 |
/// Dummy type to make it easier to create invalid iterators. |
41 | 42 |
/// See \ref INVALID for the usage. |
42 | 43 |
struct Invalid { |
43 | 44 |
public: |
44 | 45 |
bool operator==(Invalid) { return true; } |
45 | 46 |
bool operator!=(Invalid) { return false; } |
46 | 47 |
bool operator< (Invalid) { return false; } |
47 | 48 |
}; |
48 | 49 |
|
49 | 50 |
/// \brief Invalid iterators. |
50 | 51 |
/// |
51 | 52 |
/// \ref Invalid is a global type that converts to each iterator |
52 | 53 |
/// in such a way that the value of the target iterator will be invalid. |
53 | 54 |
#ifdef LEMON_ONLY_TEMPLATES |
54 | 55 |
const Invalid INVALID = Invalid(); |
55 | 56 |
#else |
56 | 57 |
extern const Invalid INVALID; |
57 | 58 |
#endif |
58 | 59 |
|
59 | 60 |
/// \addtogroup gutils |
60 | 61 |
/// @{ |
61 | 62 |
|
62 | 63 |
///Create convenience typedefs for the digraph types and iterators |
63 | 64 |
|
64 | 65 |
///This \c \#define creates convenient type definitions for the following |
65 | 66 |
///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, |
66 | 67 |
///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, |
67 | 68 |
///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. |
68 | 69 |
/// |
69 | 70 |
///\note If the graph type is a dependent type, ie. the graph type depend |
70 | 71 |
///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS() |
71 | 72 |
///macro. |
72 | 73 |
#define DIGRAPH_TYPEDEFS(Digraph) \ |
73 | 74 |
typedef Digraph::Node Node; \ |
74 | 75 |
typedef Digraph::NodeIt NodeIt; \ |
75 | 76 |
typedef Digraph::Arc Arc; \ |
76 | 77 |
typedef Digraph::ArcIt ArcIt; \ |
77 | 78 |
typedef Digraph::InArcIt InArcIt; \ |
78 | 79 |
typedef Digraph::OutArcIt OutArcIt; \ |
79 | 80 |
typedef Digraph::NodeMap<bool> BoolNodeMap; \ |
80 | 81 |
typedef Digraph::NodeMap<int> IntNodeMap; \ |
81 | 82 |
typedef Digraph::NodeMap<double> DoubleNodeMap; \ |
82 | 83 |
typedef Digraph::ArcMap<bool> BoolArcMap; \ |
83 | 84 |
typedef Digraph::ArcMap<int> IntArcMap; \ |
84 | 85 |
typedef Digraph::ArcMap<double> DoubleArcMap |
85 | 86 |
|
86 | 87 |
///Create convenience typedefs for the digraph types and iterators |
87 | 88 |
|
88 | 89 |
///\see DIGRAPH_TYPEDEFS |
89 | 90 |
/// |
90 | 91 |
///\note Use this macro, if the graph type is a dependent type, |
91 | 92 |
///ie. the graph type depend on a template parameter. |
92 | 93 |
#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \ |
93 | 94 |
typedef typename Digraph::Node Node; \ |
94 | 95 |
typedef typename Digraph::NodeIt NodeIt; \ |
95 | 96 |
typedef typename Digraph::Arc Arc; \ |
96 | 97 |
typedef typename Digraph::ArcIt ArcIt; \ |
97 | 98 |
typedef typename Digraph::InArcIt InArcIt; \ |
98 | 99 |
typedef typename Digraph::OutArcIt OutArcIt; \ |
99 | 100 |
typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \ |
100 | 101 |
typedef typename Digraph::template NodeMap<int> IntNodeMap; \ |
101 | 102 |
typedef typename Digraph::template NodeMap<double> DoubleNodeMap; \ |
102 | 103 |
typedef typename Digraph::template ArcMap<bool> BoolArcMap; \ |
103 | 104 |
typedef typename Digraph::template ArcMap<int> IntArcMap; \ |
104 | 105 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap |
105 | 106 |
|
106 | 107 |
///Create convenience typedefs for the graph types and iterators |
107 | 108 |
|
108 | 109 |
///This \c \#define creates the same convenient type definitions as defined |
109 | 110 |
///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates |
110 | 111 |
///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap, |
111 | 112 |
///\c DoubleEdgeMap. |
112 | 113 |
/// |
113 | 114 |
///\note If the graph type is a dependent type, ie. the graph type depend |
114 | 115 |
///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS() |
115 | 116 |
///macro. |
116 | 117 |
#define GRAPH_TYPEDEFS(Graph) \ |
117 | 118 |
DIGRAPH_TYPEDEFS(Graph); \ |
118 | 119 |
typedef Graph::Edge Edge; \ |
119 | 120 |
typedef Graph::EdgeIt EdgeIt; \ |
120 | 121 |
typedef Graph::IncEdgeIt IncEdgeIt; \ |
0 comments (0 inline)