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