author | ladanyi |
Tue, 14 Sep 2004 09:02:33 +0000 | |
changeset 846 | a7a406fdb006 |
child 901 | 69a8e672acb1 |
permissions | -rw-r--r-- |
deba@844 | 1 |
// -*- c++ -*- |
deba@844 | 2 |
#ifndef MAP_BITS_H |
deba@844 | 3 |
#define MAP_BITS_H |
deba@844 | 4 |
|
deba@844 | 5 |
///\ingroup graphmaps |
deba@844 | 6 |
///\file |
deba@844 | 7 |
///\brief Some utils to help implement maps. |
deba@844 | 8 |
|
deba@844 | 9 |
namespace hugo { |
deba@844 | 10 |
|
deba@844 | 11 |
|
deba@844 | 12 |
/// \addtogroup graphmaps |
deba@844 | 13 |
/// @{ |
deba@844 | 14 |
|
deba@844 | 15 |
/// Helper class to get information about the key type. |
deba@844 | 16 |
template <typename Graph, typename KeyIt> |
deba@844 | 17 |
struct KeyInfo {}; |
deba@844 | 18 |
|
deba@844 | 19 |
template <typename Graph> |
deba@844 | 20 |
struct KeyInfo<Graph, typename Graph::NodeIt> { |
deba@844 | 21 |
static int maxId(const Graph& graph) { |
deba@844 | 22 |
return graph.maxNodeId(); |
deba@844 | 23 |
} |
deba@844 | 24 |
static int id(const Graph& graph, const typename Graph::Node& node) { |
deba@844 | 25 |
return graph.id(node); |
deba@844 | 26 |
} |
deba@844 | 27 |
}; |
deba@844 | 28 |
|
deba@844 | 29 |
template <typename Graph> |
deba@844 | 30 |
struct KeyInfo<Graph, typename Graph::EdgeIt> { |
deba@844 | 31 |
static int maxId(const Graph& graph) { |
deba@844 | 32 |
return graph.maxEdgeId(); |
deba@844 | 33 |
} |
deba@844 | 34 |
static int id(const Graph& graph, const typename Graph::Edge& edge) { |
deba@844 | 35 |
return graph.id(edge); |
deba@844 | 36 |
} |
deba@844 | 37 |
}; |
deba@844 | 38 |
|
deba@844 | 39 |
template <typename Graph> |
deba@844 | 40 |
struct KeyInfo<Graph, typename Graph::SymEdgeIt> { |
deba@844 | 41 |
static int maxId(const Graph& graph) { |
deba@844 | 42 |
return graph.maxEdgeId() >> 1; |
deba@844 | 43 |
} |
deba@844 | 44 |
static int id(const Graph& graph, const typename Graph::Edge& edge) { |
deba@844 | 45 |
return graph.id(edge) >> 1; |
deba@844 | 46 |
} |
deba@844 | 47 |
}; |
deba@844 | 48 |
|
deba@844 | 49 |
/// @} |
deba@844 | 50 |
} |
deba@844 | 51 |
|
deba@844 | 52 |
#endif |