3  * This file is a part of LEMON, a generic C++ optimization library
 
     5  * Copyright (C) 2003-2007
 
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
 
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
 
     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.
 
    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
 
    19 #ifndef LEMON_BITS_DEFAULT_MAP_H
 
    20 #define LEMON_BITS_DEFAULT_MAP_H
 
    23 #include <lemon/bits/array_map.h>
 
    24 #include <lemon/bits/vector_map.h>
 
    25 #include <lemon/bits/debug_map.h>
 
    29 ///\brief Graph maps that construct and destruct their elements dynamically.
 
    34 #ifndef LEMON_USE_DEBUG_MAP
 
    36   template <typename _Graph, typename _Item, typename _Value>
 
    37   struct DefaultMapSelector {
 
    38     typedef ArrayMap<_Graph, _Item, _Value> Map;
 
    42   template <typename _Graph, typename _Item>
 
    43   struct DefaultMapSelector<_Graph, _Item, bool> {
 
    44     typedef VectorMap<_Graph, _Item, bool> Map;
 
    48   template <typename _Graph, typename _Item>
 
    49   struct DefaultMapSelector<_Graph, _Item, char> {
 
    50     typedef VectorMap<_Graph, _Item, char> Map;
 
    53   template <typename _Graph, typename _Item>
 
    54   struct DefaultMapSelector<_Graph, _Item, signed char> {
 
    55     typedef VectorMap<_Graph, _Item, signed char> Map;
 
    58   template <typename _Graph, typename _Item>
 
    59   struct DefaultMapSelector<_Graph, _Item, unsigned char> {
 
    60     typedef VectorMap<_Graph, _Item, unsigned char> Map;
 
    65   template <typename _Graph, typename _Item>
 
    66   struct DefaultMapSelector<_Graph, _Item, signed int> {
 
    67     typedef VectorMap<_Graph, _Item, signed int> Map;
 
    70   template <typename _Graph, typename _Item>
 
    71   struct DefaultMapSelector<_Graph, _Item, unsigned int> {
 
    72     typedef VectorMap<_Graph, _Item, unsigned int> Map;
 
    77   template <typename _Graph, typename _Item>
 
    78   struct DefaultMapSelector<_Graph, _Item, signed short> {
 
    79     typedef VectorMap<_Graph, _Item, signed short> Map;
 
    82   template <typename _Graph, typename _Item>
 
    83   struct DefaultMapSelector<_Graph, _Item, unsigned short> {
 
    84     typedef VectorMap<_Graph, _Item, unsigned short> Map;
 
    89   template <typename _Graph, typename _Item>
 
    90   struct DefaultMapSelector<_Graph, _Item, signed long> {
 
    91     typedef VectorMap<_Graph, _Item, signed long> Map;
 
    94   template <typename _Graph, typename _Item>
 
    95   struct DefaultMapSelector<_Graph, _Item, unsigned long> {
 
    96     typedef VectorMap<_Graph, _Item, unsigned long> Map;
 
   100 #if defined __GNUC__ && !defined __STRICT_ANSI__
 
   103   template <typename _Graph, typename _Item>
 
   104   struct DefaultMapSelector<_Graph, _Item, signed long long> {
 
   105     typedef VectorMap<_Graph, _Item, signed long long> Map;
 
   108   template <typename _Graph, typename _Item>
 
   109   struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
 
   110     typedef VectorMap<_Graph, _Item, unsigned long long> Map;
 
   117   template <typename _Graph, typename _Item>
 
   118   struct DefaultMapSelector<_Graph, _Item, float> {
 
   119     typedef VectorMap<_Graph, _Item, float> Map;
 
   124   template <typename _Graph, typename _Item>
 
   125   struct DefaultMapSelector<_Graph, _Item, double> {
 
   126     typedef VectorMap<_Graph, _Item,  double> Map;
 
   131   template <typename _Graph, typename _Item>
 
   132   struct DefaultMapSelector<_Graph, _Item, long double> {
 
   133     typedef VectorMap<_Graph, _Item, long double> Map;
 
   138   template <typename _Graph, typename _Item, typename _Ptr>
 
   139   struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
 
   140     typedef VectorMap<_Graph, _Item, _Ptr*> Map;
 
   145   template <typename _Graph, typename _Item, typename _Value>
 
   146   struct DefaultMapSelector {
 
   147     typedef DebugMap<_Graph, _Item, _Value> Map;
 
   153   template <typename _Graph, typename _Item, typename _Value>
 
   155     : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
 
   157     typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
 
   158     typedef DefaultMap<_Graph, _Item, _Value> Map;
 
   160     typedef typename Parent::Graph Graph;
 
   161     typedef typename Parent::Value Value;
 
   163     explicit DefaultMap(const Graph& graph) : Parent(graph) {}
 
   164     DefaultMap(const Graph& graph, const Value& value) 
 
   165       : Parent(graph, value) {}
 
   167     DefaultMap& operator=(const DefaultMap& cmap) {
 
   168       return operator=<DefaultMap>(cmap);
 
   171     template <typename CMap>
 
   172     DefaultMap& operator=(const CMap& cmap) {
 
   173       Parent::operator=(cmap);