alpar@906: /* -*- C++ -*- alpar@906: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@1956: * Copyright (C) 2003-2006 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: alpar@921: #ifndef LEMON_DEFAULT_MAP_H alpar@921: #define LEMON_DEFAULT_MAP_H deba@822: deba@822: deba@1307: #include deba@1307: #include deba@1979: #include deba@822: alpar@1946: ///\ingroup graphmapfactory deba@822: ///\file klao@946: ///\brief Graph maps that construct and destruct deba@822: ///their elements dynamically. deba@822: alpar@921: namespace lemon { deba@1966: deba@1979: deba@1979: #ifndef _GLIBCXX_DEBUG deba@822: deba@1966: template deba@1966: struct DefaultMapSelector { deba@1966: typedef ArrayMap<_Graph, _Item, _Value> Map; deba@1966: }; deba@1966: deba@1966: #else deba@822: deba@1267: template klao@946: struct DefaultMapSelector { deba@1965: typedef VectorMap<_Graph, _Item, _Value> Map; klao@946: }; deba@822: deba@1966: #endif 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@1965: #ifndef __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@1669: /// \e deba@1267: template < deba@1267: typename _Graph, deba@1267: typename _Item, deba@1267: typename _Value> 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: deba@980: DefaultMap(const Graph& _g) : Parent(_g) {} alpar@987: DefaultMap(const Graph& _g, const Value& _v) : Parent(_g, _v) {} deba@1669: klao@946: }; klao@946: deba@822: } deba@822: deba@822: #endif