maps.h

Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 * src/lemon/skeletons/maps.h - Part of LEMON, a generic C++ optimization library 00003 * 00004 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 00005 * (Egervary Combinatorial Optimization Research Group, EGRES). 00006 * 00007 * Permission to use, modify and distribute this software is granted 00008 * provided that this copyright notice appears in all copies. For 00009 * precise terms see the accompanying LICENSE file. 00010 * 00011 * This software is provided "AS IS" with no warranty of any kind, 00012 * express or implied, and with no claim as to its suitability for any 00013 * purpose. 00014 * 00015 */ 00016 00017 #ifndef LEMON_MAPSKELETON_H 00018 #define LEMON_MAPSKELETON_H 00019 00023 00024 namespace lemon { 00025 00026 namespace skeleton { 00027 00030 00032 template<typename K, typename T> 00033 class ReadMap 00034 { 00035 public: 00037 typedef K KeyType; 00039 typedef T ValueType; 00040 00042 ValueType operator[](const KeyType &k) const {return ValueType();} 00043 00045 ReadMap() {} 00046 }; 00047 00048 00050 template<typename K, typename T> 00051 class WriteMap 00052 { 00053 public: 00055 typedef K KeyType; 00057 typedef T ValueType; 00058 00060 void set(const KeyType &k,const ValueType &t) {} 00061 00063 WriteMap() {} 00064 }; 00065 00067 template<typename K, typename T> 00068 class ReadWriteMap : public ReadMap<K,T>, 00069 public WriteMap<K,T> 00070 { 00071 public: 00073 typedef K KeyType; 00075 typedef T ValueType; 00076 00078 ValueType operator[](const KeyType &k) const {return ValueType();} 00080 void set(const KeyType &k,const ValueType &t) {} 00081 00083 ReadWriteMap() {} 00084 }; 00085 00086 00088 template<typename K, typename T> 00089 class ReferenceMap : public ReadWriteMap<K,T> 00090 { 00091 public: 00093 typedef K KeyType; 00095 typedef T ValueType; 00096 00097 protected: 00098 ValueType tmp; 00099 public: 00100 typedef ValueType& ReferenceType; 00102 typedef const ValueType& ConstReferenceType; 00103 00105 ReferenceType operator[](const KeyType &i) { return tmp; } 00107 ConstReferenceType operator[](const KeyType &i) const 00108 { return tmp; } 00110 void set(const KeyType &k,const ValueType &t) { operator[](k)=t; } 00111 00113 ReferenceMap() {} 00114 }; 00115 00116 // @} 00117 00118 } //namespace skeleton 00119 } //namespace lemon 00120 #endif // LEMON_MAPSKELETON_H

Generated on Thu Sep 30 12:18:33 2004 for LEMON by doxygen 1.3.8