1 | /* -*- C++ -*- |
---|
2 | * src/lemon/map_bits.h - Part of LEMON, a generic C++ optimization library |
---|
3 | * |
---|
4 | * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
5 | * (Egervary Combinatorial Optimization Research Group, EGRES). |
---|
6 | * |
---|
7 | * Permission to use, modify and distribute this software is granted |
---|
8 | * provided that this copyright notice appears in all copies. For |
---|
9 | * precise terms see the accompanying LICENSE file. |
---|
10 | * |
---|
11 | * This software is provided "AS IS" with no warranty of any kind, |
---|
12 | * express or implied, and with no claim as to its suitability for any |
---|
13 | * purpose. |
---|
14 | * |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef LEMON_MAP_BITS_H |
---|
18 | #define LEMON_MAP_BITS_H |
---|
19 | |
---|
20 | ///\ingroup graphmaps |
---|
21 | ///\file |
---|
22 | ///\brief Some utils to help implement maps. |
---|
23 | |
---|
24 | namespace lemon { |
---|
25 | |
---|
26 | |
---|
27 | /// \addtogroup graphmaps |
---|
28 | /// @{ |
---|
29 | |
---|
30 | /// Helper class to get information about the key type. |
---|
31 | template <typename Graph, typename KeyIt> |
---|
32 | struct KeyInfo {}; |
---|
33 | |
---|
34 | template <typename Graph> |
---|
35 | struct KeyInfo<Graph, typename Graph::NodeIt> { |
---|
36 | static int maxId(const Graph& graph) { |
---|
37 | return graph.maxNodeId(); |
---|
38 | } |
---|
39 | static int id(const Graph& graph, const typename Graph::Node& node) { |
---|
40 | return graph.id(node); |
---|
41 | } |
---|
42 | }; |
---|
43 | |
---|
44 | template <typename Graph> |
---|
45 | struct KeyInfo<Graph, typename Graph::EdgeIt> { |
---|
46 | static int maxId(const Graph& graph) { |
---|
47 | return graph.maxEdgeId(); |
---|
48 | } |
---|
49 | static int id(const Graph& graph, const typename Graph::Edge& edge) { |
---|
50 | return graph.id(edge); |
---|
51 | } |
---|
52 | }; |
---|
53 | |
---|
54 | template <typename Graph> |
---|
55 | struct KeyInfo<Graph, typename Graph::SymEdgeIt> { |
---|
56 | static int maxId(const Graph& graph) { |
---|
57 | return graph.maxSymEdgeId(); |
---|
58 | } |
---|
59 | static int id(const Graph& graph, const typename Graph::SymEdge& edge) { |
---|
60 | return graph.id(edge); |
---|
61 | } |
---|
62 | }; |
---|
63 | |
---|
64 | /// @} |
---|
65 | } |
---|
66 | |
---|
67 | #endif |
---|