lemon/bits/default_map.h
changeset 269 f5965bbf1353
parent 107 31a2e6d28f61
child 313 64f8f7cc6168
equal deleted inserted replaced
1:30f5e7252d64 2:d712f1d74686
     1 /* -*- C++ -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2008
     5  * Copyright (C) 2003-2008
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
    27 ///\ingroup graphbits
    27 ///\ingroup graphbits
    28 ///\file
    28 ///\file
    29 ///\brief Graph maps that construct and destruct their elements dynamically.
    29 ///\brief Graph maps that construct and destruct their elements dynamically.
    30 
    30 
    31 namespace lemon {
    31 namespace lemon {
    32   
    32 
    33   
    33 
    34   //#ifndef LEMON_USE_DEBUG_MAP
    34   //#ifndef LEMON_USE_DEBUG_MAP
    35 
    35 
    36   template <typename _Graph, typename _Item, typename _Value>
    36   template <typename _Graph, typename _Item, typename _Value>
    37   struct DefaultMapSelector {
    37   struct DefaultMapSelector {
    38     typedef ArrayMap<_Graph, _Item, _Value> Map;
    38     typedef ArrayMap<_Graph, _Item, _Value> Map;
   138   template <typename _Graph, typename _Item, typename _Ptr>
   138   template <typename _Graph, typename _Item, typename _Ptr>
   139   struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
   139   struct DefaultMapSelector<_Graph, _Item, _Ptr*> {
   140     typedef VectorMap<_Graph, _Item, _Ptr*> Map;
   140     typedef VectorMap<_Graph, _Item, _Ptr*> Map;
   141   };
   141   };
   142 
   142 
   143 // #else 
   143 // #else
   144 
   144 
   145 //   template <typename _Graph, typename _Item, typename _Value>
   145 //   template <typename _Graph, typename _Item, typename _Value>
   146 //   struct DefaultMapSelector {
   146 //   struct DefaultMapSelector {
   147 //     typedef DebugMap<_Graph, _Item, _Value> Map;
   147 //     typedef DebugMap<_Graph, _Item, _Value> Map;
   148 //   };
   148 //   };
   149 
   149 
   150 // #endif  
   150 // #endif
   151 
   151 
   152   /// \e
   152   /// \e
   153   template <typename _Graph, typename _Item, typename _Value>
   153   template <typename _Graph, typename _Item, typename _Value>
   154   class DefaultMap 
   154   class DefaultMap
   155     : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
   155     : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
   156   public:
   156   public:
   157     typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
   157     typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
   158     typedef DefaultMap<_Graph, _Item, _Value> Map;
   158     typedef DefaultMap<_Graph, _Item, _Value> Map;
   159     
   159 
   160     typedef typename Parent::Graph Graph;
   160     typedef typename Parent::Graph Graph;
   161     typedef typename Parent::Value Value;
   161     typedef typename Parent::Value Value;
   162 
   162 
   163     explicit DefaultMap(const Graph& graph) : Parent(graph) {}
   163     explicit DefaultMap(const Graph& graph) : Parent(graph) {}
   164     DefaultMap(const Graph& graph, const Value& value) 
   164     DefaultMap(const Graph& graph, const Value& value)
   165       : Parent(graph, value) {}
   165       : Parent(graph, value) {}
   166 
   166 
   167     DefaultMap& operator=(const DefaultMap& cmap) {
   167     DefaultMap& operator=(const DefaultMap& cmap) {
   168       return operator=<DefaultMap>(cmap);
   168       return operator=<DefaultMap>(cmap);
   169     }
   169     }