diff -r 8ef02f0c4245 -r ef2d00e46897 lemon/vmap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lemon/vmap.h Wed Feb 22 12:45:59 2006 +0000 @@ -0,0 +1,112 @@ +/* -*- C++ -*- + * + * This file is a part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2003-2006 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +#ifndef LEMON_LIST_GRAPH_H +#define LEMON_LIST_GRAPH_H + +///\ingroup graphs +///\file +///\brief Virtual map support. + +namespace lemon { + + ///Base class of the virtual maps. + template + class VMapBase + { + public: + ///\e + typedef K Key; + ///\e + typedef V Value; + + ///\e + virtual Value operator[](const Key &) const { return Value();} + ///\e + virtual void set(const Key &,const Value &) {} + }; + + ///Base class of the virtual reference maps. + template + class VRefMapBase + { + public: + ///\e + typedef K Key; + ///\e + typedef V Value; + + ///\e + virtual Value& operator[](Key &) = 0; + ///\e + virtual Value& operator[](const Key &) const = 0; + ///\e + virtual void set(const Key &,const Value &) = 0; + }; + + ///Makes a virtual map from a \ref concept::ReadMap "ReadMap" + template + class VReadMap : public VMapBase + { + const M ↦ + public: + ///\e + VReadMap(const M &m) : map(m) {} + virtual Value operator[](const Key &k) const { return map[k];} + }; + + ///Function interface for \ref VReadMap. + template + vReadMap(const M& m) {return VReadMap(m);} + + ///Makes a virtual map from a \ref concept::WriteMap "WriteMap" + template + class VWriteMap :public VMapBase + { + M ↦ + public: + ///\e + VWriteMap(M &m) : map(m) {} + virtual void set(const Key &k,const Value &v) { map.set(k,v);} + }; + + ///Function interface for \ref VWriteMap. + template + vWriteMap(const M& m) {return VReadMap(m);} + + ///Makes a virtual map from a \ref concept::ReadWriteMap "ReadWriteMap" + template + class VReadWriteMap :public VMapBase + { + M ↦ + public: + ///\e + VReadWriteMap(M &m) : map(m) {} + virtual Value operator[](const Key &k) const { return map[k];} + virtual void set(const Key &k,const Value &v) { map.set(k,v);} + }; + + ///Function interface for \ref VReadWriteMap. + template + vReadWriteMap(const M& m) {return VReadMap(m);} + + /// @} +} //namespace lemon + + +#endif