lemon/bits/default_map.h
author deba
Wed, 22 Feb 2006 18:26:56 +0000
changeset 1979 c2992fd74dad
parent 1966 65765fb5eb2f
child 1996 5dc13b93f8b4
permissions -rw-r--r--
Mergeing extendermerge branch
Changes:
the extender system
resize for static size graph
UGraphExtender => UndirectGraphExtender
UGraphExtenders with changed meaning
Some UGraphExtender /SubUGraphExtenders, DirectUGraphExtender/
GridGraph => GridUGraph
radix sort to ansi compatible
alpar@906
     1
/* -*- C++ -*-
alpar@906
     2
 *
alpar@1956
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@1956
     4
 *
alpar@1956
     5
 * Copyright (C) 2003-2006
alpar@1956
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1956
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@906
     8
 *
alpar@906
     9
 * Permission to use, modify and distribute this software is granted
alpar@906
    10
 * provided that this copyright notice appears in all copies. For
alpar@906
    11
 * precise terms see the accompanying LICENSE file.
alpar@906
    12
 *
alpar@906
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    14
 * express or implied, and with no claim as to its suitability for any
alpar@906
    15
 * purpose.
alpar@906
    16
 *
alpar@906
    17
 */
alpar@906
    18
alpar@921
    19
#ifndef LEMON_DEFAULT_MAP_H
alpar@921
    20
#define LEMON_DEFAULT_MAP_H
deba@822
    21
deba@822
    22
deba@1307
    23
#include <lemon/bits/array_map.h>
deba@1307
    24
#include <lemon/bits/vector_map.h>
deba@1979
    25
#include <lemon/bits/static_map.h>
deba@822
    26
alpar@1946
    27
///\ingroup graphmapfactory
deba@822
    28
///\file
klao@946
    29
///\brief Graph maps that construct and destruct
deba@822
    30
///their elements dynamically.
deba@822
    31
alpar@921
    32
namespace lemon {
deba@1966
    33
  
deba@1979
    34
  
deba@1979
    35
#ifndef _GLIBCXX_DEBUG
deba@822
    36
deba@1966
    37
  template <typename _Graph, typename _Item, typename _Value>
deba@1966
    38
  struct DefaultMapSelector {
deba@1966
    39
    typedef ArrayMap<_Graph, _Item, _Value> Map;
deba@1966
    40
  };
deba@1966
    41
deba@1966
    42
#else
deba@822
    43
deba@1267
    44
  template <typename _Graph, typename _Item, typename _Value>
klao@946
    45
  struct DefaultMapSelector {
deba@1965
    46
    typedef VectorMap<_Graph, _Item, _Value> Map;
klao@946
    47
  };
deba@822
    48
deba@1966
    49
#endif
deba@1966
    50
klao@946
    51
  // bool
deba@1267
    52
  template <typename _Graph, typename _Item>
deba@1267
    53
  struct DefaultMapSelector<_Graph, _Item, bool> {
deba@980
    54
    typedef VectorMap<_Graph, _Item, bool> Map;
klao@946
    55
  };
deba@822
    56
klao@946
    57
  // char
deba@1267
    58
  template <typename _Graph, typename _Item>
deba@1267
    59
  struct DefaultMapSelector<_Graph, _Item, char> {
deba@980
    60
    typedef VectorMap<_Graph, _Item, char> Map;
klao@946
    61
  };
deba@822
    62
deba@1267
    63
  template <typename _Graph, typename _Item>
deba@1267
    64
  struct DefaultMapSelector<_Graph, _Item, signed char> {
deba@980
    65
    typedef VectorMap<_Graph, _Item, signed char> Map;
klao@946
    66
  };
deba@822
    67
deba@1267
    68
  template <typename _Graph, typename _Item>
deba@1267
    69
  struct DefaultMapSelector<_Graph, _Item, unsigned char> {
deba@980
    70
    typedef VectorMap<_Graph, _Item, unsigned char> Map;
klao@946
    71
  };
deba@822
    72
deba@822
    73
klao@946
    74
  // int
deba@1267
    75
  template <typename _Graph, typename _Item>
deba@1267
    76
  struct DefaultMapSelector<_Graph, _Item, signed int> {
deba@980
    77
    typedef VectorMap<_Graph, _Item, signed int> Map;
klao@946
    78
  };
deba@822
    79
deba@1267
    80
  template <typename _Graph, typename _Item>
deba@1267
    81
  struct DefaultMapSelector<_Graph, _Item, unsigned int> {
deba@980
    82
    typedef VectorMap<_Graph, _Item, unsigned int> Map;
klao@946
    83
  };
deba@822
    84
deba@822
    85
klao@946
    86
  // short
deba@1267
    87
  template <typename _Graph, typename _Item>
deba@1267
    88
  struct DefaultMapSelector<_Graph, _Item, signed short> {
deba@980
    89
    typedef VectorMap<_Graph, _Item, signed short> Map;
klao@946
    90
  };
deba@822
    91
deba@1267
    92
  template <typename _Graph, typename _Item>
deba@1267
    93
  struct DefaultMapSelector<_Graph, _Item, unsigned short> {
deba@980
    94
    typedef VectorMap<_Graph, _Item, unsigned short> Map;
klao@946
    95
  };
klao@946
    96
klao@946
    97
klao@946
    98
  // long
deba@1267
    99
  template <typename _Graph, typename _Item>
deba@1267
   100
  struct DefaultMapSelector<_Graph, _Item, signed long> {
deba@980
   101
    typedef VectorMap<_Graph, _Item, signed long> Map;
klao@946
   102
  };
klao@946
   103
deba@1267
   104
  template <typename _Graph, typename _Item>
deba@1267
   105
  struct DefaultMapSelector<_Graph, _Item, unsigned long> {
deba@980
   106
    typedef VectorMap<_Graph, _Item, unsigned long> Map;
klao@946
   107
  };
klao@946
   108
deba@1965
   109
deba@1965
   110
#ifndef __STRICT_ANSI__
deba@1965
   111
deba@1965
   112
  // long long
deba@1965
   113
  template <typename _Graph, typename _Item>
deba@1965
   114
  struct DefaultMapSelector<_Graph, _Item, signed long long> {
deba@1965
   115
    typedef VectorMap<_Graph, _Item, signed long long> Map;
deba@1965
   116
  };
deba@1965
   117
deba@1965
   118
  template <typename _Graph, typename _Item>
deba@1965
   119
  struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
deba@1965
   120
    typedef VectorMap<_Graph, _Item, unsigned long long> Map;
deba@1965
   121
  };
deba@1965
   122
deba@1965
   123
#endif
klao@946
   124
klao@946
   125
klao@946
   126
  // float
deba@1267
   127
  template <typename _Graph, typename _Item>
deba@1267
   128
  struct DefaultMapSelector<_Graph, _Item, float> {
deba@980
   129
    typedef VectorMap<_Graph, _Item, float> Map;
klao@946
   130
  };
klao@946
   131
klao@946
   132
klao@946
   133
  // double
deba@1267
   134
  template <typename _Graph, typename _Item>
deba@1267
   135
  struct DefaultMapSelector<_Graph, _Item, double> {
deba@980
   136
    typedef VectorMap<_Graph, _Item,  double> Map;
klao@946
   137
  };
klao@946
   138
klao@946
   139
klao@946
   140
  // long double
deba@1267
   141
  template <typename _Graph, typename _Item>
deba@1267
   142
  struct DefaultMapSelector<_Graph, _Item, long double> {
deba@980
   143
    typedef VectorMap<_Graph, _Item, long double> Map;
klao@946
   144
  };
klao@946
   145
klao@946
   146
klao@946
   147
  // pointer
deba@1267
   148
  template <typename _Graph, typename _Item, typename _Ptr>
deba@1267
   149
  struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
deba@980
   150
    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
klao@946
   151
  };
klao@946
   152
deba@1669
   153
  /// \e
deba@1267
   154
  template <
deba@1267
   155
    typename _Graph, 
deba@1267
   156
    typename _Item,
deba@1267
   157
    typename _Value>
deba@1267
   158
  class DefaultMap 
deba@1267
   159
    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
klao@946
   160
  public:
deba@1267
   161
    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
deba@1267
   162
    typedef DefaultMap<_Graph, _Item, _Value> Map;
klao@946
   163
    
klao@946
   164
    typedef typename Parent::Graph Graph;
alpar@987
   165
    typedef typename Parent::Value Value;
klao@946
   166
deba@980
   167
    DefaultMap(const Graph& _g) : Parent(_g) {}
alpar@987
   168
    DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {}
deba@1669
   169
klao@946
   170
  };
klao@946
   171
deba@822
   172
}
deba@822
   173
deba@822
   174
#endif