sym_map.h

Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 * src/lemon/sym_map.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_SYM_MAP_H 00018 #define LEMON_SYM_MAP_H 00019 00024 00025 namespace lemon { 00026 00029 00036 template <typename Graph, typename Edge, typename EdgeIt> 00037 class SymEdgeIt : public EdgeIt { 00038 public: 00039 00042 SymEdgeIt() 00043 : EdgeIt() {} 00044 00047 SymEdgeIt(const Graph& graph) 00048 : EdgeIt(graph) { 00049 while ( (EdgeIt::n & 1) && EdgeIt::n != -1) { 00050 EdgeIt::operator++(); 00051 } 00052 } 00053 00056 SymEdgeIt(Invalid invalid) 00057 : EdgeIt(invalid) {} 00058 00061 SymEdgeIt(const Graph& graph, const Edge& edge) 00062 : EdgeIt(graph, edge) { 00063 while ( (EdgeIt::n & 1) && EdgeIt::n != -1) { 00064 EdgeIt::operator++(); 00065 } 00066 } 00067 00070 SymEdgeIt& operator++() { 00071 EdgeIt::operator++(); 00072 while ( (EdgeIt::n & 1) && EdgeIt::n != -1) { 00073 EdgeIt::operator++(); 00074 } 00075 return *this; 00076 } 00077 }; 00078 00085 template <template <typename, typename> class DynMap, 00086 typename MapRegistry, typename Value> 00087 class SymMap : public DynMap<MapRegistry, Value>{ 00088 00089 private: 00090 00091 typedef DynMap<MapRegistry, Value> MapImpl; 00092 00093 public: 00094 00096 typedef typename MapRegistry::Graph Graph; 00097 00098 typedef typename MapImpl::KeyType KeyType; 00099 00100 public: 00101 00102 00105 SymMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} 00106 00109 SymMap(const Graph& g, MapRegistry& r, const Value& v) 00110 : MapImpl(g, r, v) {} 00111 00114 SymMap(const SymMap& copy) 00115 : MapImpl(static_cast<const MapImpl&>(copy)) {} 00116 00119 SymMap& operator=(const SymMap& copy) { 00120 MapImpl::operator=(static_cast<const MapImpl&>(copy)); 00121 return *this; 00122 } 00123 00126 void add(const KeyType& key) { 00127 int id = MapImpl::getGraph()->id(key); 00128 if (id & 1) return; 00129 MapImpl::add(key); 00130 } 00131 00134 void erase(const KeyType& key) { 00135 int id = MapImpl::getGraph()->id(key); 00136 if (id & 1) return; 00137 MapImpl::add(key); 00138 } 00139 }; 00140 00142 } 00143 00144 #endif

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