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