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