alpar@906: /* -*- C++ -*- alpar@906: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@2553: * Copyright (C) 2003-2008 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1956: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@906: * alpar@906: * Permission to use, modify and distribute this software is granted alpar@906: * provided that this copyright notice appears in all copies. For alpar@906: * precise terms see the accompanying LICENSE file. alpar@906: * alpar@906: * This software is provided "AS IS" with no warranty of any kind, alpar@906: * express or implied, and with no claim as to its suitability for any alpar@906: * purpose. alpar@906: * alpar@906: */ alpar@906: deba@1999: #ifndef LEMON_BITS_DEFAULT_MAP_H deba@1999: #define LEMON_BITS_DEFAULT_MAP_H deba@822: deba@822: deba@1307: #include deba@1307: #include deba@2202: #include deba@822: deba@1996: ///\ingroup graphbits deba@822: ///\file deba@1999: ///\brief Graph maps that construct and destruct their elements dynamically. deba@822: alpar@921: namespace lemon { deba@1966: deba@1979: deba@2333: #ifndef LEMON_USE_DEBUG_MAP deba@822: deba@1966: template deba@1966: struct DefaultMapSelector { deba@1966: typedef ArrayMap<_Graph, _Item, _Value> Map; deba@1966: }; deba@1966: klao@946: // bool deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, bool> { deba@980: typedef VectorMap<_Graph, _Item, bool> Map; klao@946: }; deba@822: klao@946: // char deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, char> { deba@980: typedef VectorMap<_Graph, _Item, char> Map; klao@946: }; deba@822: deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, signed char> { deba@980: typedef VectorMap<_Graph, _Item, signed char> Map; klao@946: }; deba@822: deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, unsigned char> { deba@980: typedef VectorMap<_Graph, _Item, unsigned char> Map; klao@946: }; deba@822: deba@822: klao@946: // int deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, signed int> { deba@980: typedef VectorMap<_Graph, _Item, signed int> Map; klao@946: }; deba@822: deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, unsigned int> { deba@980: typedef VectorMap<_Graph, _Item, unsigned int> Map; klao@946: }; deba@822: deba@822: klao@946: // short deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, signed short> { deba@980: typedef VectorMap<_Graph, _Item, signed short> Map; klao@946: }; deba@822: deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, unsigned short> { deba@980: typedef VectorMap<_Graph, _Item, unsigned short> Map; klao@946: }; klao@946: klao@946: klao@946: // long deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, signed long> { deba@980: typedef VectorMap<_Graph, _Item, signed long> Map; klao@946: }; klao@946: deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, unsigned long> { deba@980: typedef VectorMap<_Graph, _Item, unsigned long> Map; klao@946: }; klao@946: deba@1965: deba@2164: #if defined __GNUC__ && !defined __STRICT_ANSI__ deba@1965: deba@1965: // long long deba@1965: template deba@1965: struct DefaultMapSelector<_Graph, _Item, signed long long> { deba@1965: typedef VectorMap<_Graph, _Item, signed long long> Map; deba@1965: }; deba@1965: deba@1965: template deba@1965: struct DefaultMapSelector<_Graph, _Item, unsigned long long> { deba@1965: typedef VectorMap<_Graph, _Item, unsigned long long> Map; deba@1965: }; deba@1965: deba@1965: #endif klao@946: klao@946: klao@946: // float deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, float> { deba@980: typedef VectorMap<_Graph, _Item, float> Map; klao@946: }; klao@946: klao@946: klao@946: // double deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, double> { deba@980: typedef VectorMap<_Graph, _Item, double> Map; klao@946: }; klao@946: klao@946: klao@946: // long double deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, long double> { deba@980: typedef VectorMap<_Graph, _Item, long double> Map; klao@946: }; klao@946: klao@946: klao@946: // pointer deba@1267: template deba@1267: struct DefaultMapSelector<_Graph, _Item, _Ptr*> { deba@980: typedef VectorMap<_Graph, _Item, _Ptr*> Map; klao@946: }; klao@946: deba@2202: #else deba@2202: deba@2202: template deba@2202: struct DefaultMapSelector { deba@2202: typedef DebugMap<_Graph, _Item, _Value> Map; deba@2202: }; deba@2202: deba@2202: #endif deba@2202: deba@1669: /// \e deba@1999: template deba@1267: class DefaultMap deba@1267: : public DefaultMapSelector<_Graph, _Item, _Value>::Map { klao@946: public: deba@1267: typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; deba@1267: typedef DefaultMap<_Graph, _Item, _Value> Map; klao@946: klao@946: typedef typename Parent::Graph Graph; alpar@987: typedef typename Parent::Value Value; klao@946: klao@2046: explicit DefaultMap(const Graph& graph) : Parent(graph) {} deba@1999: DefaultMap(const Graph& graph, const Value& value) deba@1999: : Parent(graph, value) {} deba@1669: deba@2031: DefaultMap& operator=(const DefaultMap& cmap) { deba@2031: return operator=(cmap); deba@2031: } deba@2031: deba@2031: template deba@2031: DefaultMap& operator=(const CMap& cmap) { deba@2031: Parent::operator=(cmap); deba@2031: return *this; deba@2031: } deba@2031: klao@946: }; klao@946: deba@822: } deba@822: deba@822: #endif