lemon/bits/default_map.h
author deba
Tue, 04 Apr 2006 17:43:23 +0000
changeset 2037 32e4bebee616
parent 1999 2ff283124dfc
child 2046 66d160810c0a
permissions -rw-r--r--
Doxygen log corrections

doc of ResGraphAdaptor has a bug in graph_adaptor.h
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
deba@1999
    19
#ifndef LEMON_BITS_DEFAULT_MAP_H
deba@1999
    20
#define LEMON_BITS_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@822
    25
deba@1996
    26
///\ingroup graphbits
deba@822
    27
///\file
deba@1999
    28
///\brief Graph maps that construct and destruct their elements dynamically.
deba@822
    29
alpar@921
    30
namespace lemon {
deba@1966
    31
  
deba@1979
    32
  
deba@1979
    33
#ifndef _GLIBCXX_DEBUG
deba@822
    34
deba@1966
    35
  template <typename _Graph, typename _Item, typename _Value>
deba@1966
    36
  struct DefaultMapSelector {
deba@1966
    37
    typedef ArrayMap<_Graph, _Item, _Value> Map;
deba@1966
    38
  };
deba@1966
    39
deba@1966
    40
#else
deba@822
    41
deba@1267
    42
  template <typename _Graph, typename _Item, typename _Value>
klao@946
    43
  struct DefaultMapSelector {
deba@1965
    44
    typedef VectorMap<_Graph, _Item, _Value> Map;
klao@946
    45
  };
deba@822
    46
deba@1966
    47
#endif
deba@1966
    48
klao@946
    49
  // bool
deba@1267
    50
  template <typename _Graph, typename _Item>
deba@1267
    51
  struct DefaultMapSelector<_Graph, _Item, bool> {
deba@980
    52
    typedef VectorMap<_Graph, _Item, bool> Map;
klao@946
    53
  };
deba@822
    54
klao@946
    55
  // char
deba@1267
    56
  template <typename _Graph, typename _Item>
deba@1267
    57
  struct DefaultMapSelector<_Graph, _Item, char> {
deba@980
    58
    typedef VectorMap<_Graph, _Item, char> Map;
klao@946
    59
  };
deba@822
    60
deba@1267
    61
  template <typename _Graph, typename _Item>
deba@1267
    62
  struct DefaultMapSelector<_Graph, _Item, signed char> {
deba@980
    63
    typedef VectorMap<_Graph, _Item, signed char> Map;
klao@946
    64
  };
deba@822
    65
deba@1267
    66
  template <typename _Graph, typename _Item>
deba@1267
    67
  struct DefaultMapSelector<_Graph, _Item, unsigned char> {
deba@980
    68
    typedef VectorMap<_Graph, _Item, unsigned char> Map;
klao@946
    69
  };
deba@822
    70
deba@822
    71
klao@946
    72
  // int
deba@1267
    73
  template <typename _Graph, typename _Item>
deba@1267
    74
  struct DefaultMapSelector<_Graph, _Item, signed int> {
deba@980
    75
    typedef VectorMap<_Graph, _Item, signed int> Map;
klao@946
    76
  };
deba@822
    77
deba@1267
    78
  template <typename _Graph, typename _Item>
deba@1267
    79
  struct DefaultMapSelector<_Graph, _Item, unsigned int> {
deba@980
    80
    typedef VectorMap<_Graph, _Item, unsigned int> Map;
klao@946
    81
  };
deba@822
    82
deba@822
    83
klao@946
    84
  // short
deba@1267
    85
  template <typename _Graph, typename _Item>
deba@1267
    86
  struct DefaultMapSelector<_Graph, _Item, signed short> {
deba@980
    87
    typedef VectorMap<_Graph, _Item, signed short> Map;
klao@946
    88
  };
deba@822
    89
deba@1267
    90
  template <typename _Graph, typename _Item>
deba@1267
    91
  struct DefaultMapSelector<_Graph, _Item, unsigned short> {
deba@980
    92
    typedef VectorMap<_Graph, _Item, unsigned short> Map;
klao@946
    93
  };
klao@946
    94
klao@946
    95
klao@946
    96
  // long
deba@1267
    97
  template <typename _Graph, typename _Item>
deba@1267
    98
  struct DefaultMapSelector<_Graph, _Item, signed long> {
deba@980
    99
    typedef VectorMap<_Graph, _Item, signed long> Map;
klao@946
   100
  };
klao@946
   101
deba@1267
   102
  template <typename _Graph, typename _Item>
deba@1267
   103
  struct DefaultMapSelector<_Graph, _Item, unsigned long> {
deba@980
   104
    typedef VectorMap<_Graph, _Item, unsigned long> Map;
klao@946
   105
  };
klao@946
   106
deba@1965
   107
deba@1965
   108
#ifndef __STRICT_ANSI__
deba@1965
   109
deba@1965
   110
  // long long
deba@1965
   111
  template <typename _Graph, typename _Item>
deba@1965
   112
  struct DefaultMapSelector<_Graph, _Item, signed long long> {
deba@1965
   113
    typedef VectorMap<_Graph, _Item, signed long long> Map;
deba@1965
   114
  };
deba@1965
   115
deba@1965
   116
  template <typename _Graph, typename _Item>
deba@1965
   117
  struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
deba@1965
   118
    typedef VectorMap<_Graph, _Item, unsigned long long> Map;
deba@1965
   119
  };
deba@1965
   120
deba@1965
   121
#endif
klao@946
   122
klao@946
   123
klao@946
   124
  // float
deba@1267
   125
  template <typename _Graph, typename _Item>
deba@1267
   126
  struct DefaultMapSelector<_Graph, _Item, float> {
deba@980
   127
    typedef VectorMap<_Graph, _Item, float> Map;
klao@946
   128
  };
klao@946
   129
klao@946
   130
klao@946
   131
  // double
deba@1267
   132
  template <typename _Graph, typename _Item>
deba@1267
   133
  struct DefaultMapSelector<_Graph, _Item, double> {
deba@980
   134
    typedef VectorMap<_Graph, _Item,  double> Map;
klao@946
   135
  };
klao@946
   136
klao@946
   137
klao@946
   138
  // long double
deba@1267
   139
  template <typename _Graph, typename _Item>
deba@1267
   140
  struct DefaultMapSelector<_Graph, _Item, long double> {
deba@980
   141
    typedef VectorMap<_Graph, _Item, long double> Map;
klao@946
   142
  };
klao@946
   143
klao@946
   144
klao@946
   145
  // pointer
deba@1267
   146
  template <typename _Graph, typename _Item, typename _Ptr>
deba@1267
   147
  struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
deba@980
   148
    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
klao@946
   149
  };
klao@946
   150
deba@1669
   151
  /// \e
deba@1999
   152
  template <typename _Graph, typename _Item, typename _Value>
deba@1267
   153
  class DefaultMap 
deba@1267
   154
    : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
klao@946
   155
  public:
deba@1267
   156
    typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
deba@1267
   157
    typedef DefaultMap<_Graph, _Item, _Value> Map;
klao@946
   158
    
klao@946
   159
    typedef typename Parent::Graph Graph;
alpar@987
   160
    typedef typename Parent::Value Value;
klao@946
   161
deba@1999
   162
    DefaultMap(const Graph& graph) : Parent(graph) {}
deba@1999
   163
    DefaultMap(const Graph& graph, const Value& value) 
deba@1999
   164
      : Parent(graph, value) {}
deba@1669
   165
deba@2031
   166
    DefaultMap& operator=(const DefaultMap& cmap) {
deba@2031
   167
      return operator=<DefaultMap>(cmap);
deba@2031
   168
    }
deba@2031
   169
deba@2031
   170
    template <typename CMap>
deba@2031
   171
    DefaultMap& operator=(const CMap& cmap) {
deba@2031
   172
      Parent::operator=(cmap);
deba@2031
   173
      return *this;
deba@2031
   174
    }
deba@2031
   175
klao@946
   176
  };
klao@946
   177
deba@822
   178
}
deba@822
   179
deba@822
   180
#endif