Changeset 897:ef09eee53b09 in lemon-0.x
- Timestamp:
- 09/22/04 10:04:31 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1205
- Location:
- src/hugo
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hugo/array_map.h
r891 r897 30 30 template <typename MapRegistry, typename Value> 31 31 class ArrayMap : public MapRegistry::MapBase { 32 33 template <typename MR, typename V> friend class ArrayMap; 32 34 33 35 public: … … 64 66 65 67 66 /** Default constructor for the map.67 */68 ArrayMap() : capacity(0), values(0) {}69 70 68 /** Graph and Registry initialized map constructor. 71 69 */ … … 119 117 ArrayMap& operator=(const ArrayMap& copy) { 120 118 if (© == this) return *this; 121 122 if (capacity != 0) { 123 MapBase::destroy(); 124 allocator.deallocate(values, capacity); 125 } 126 127 MapBase::operator=(copy); 128 129 capacity = copy.capacity; 130 if (capacity == 0) return *this; 131 values = allocator.allocate(capacity); 119 120 if (MapBase::getGraph() != copy.getGraph()) { 121 if (capacity != 0) { 122 MapBase::destroy(); 123 allocator.deallocate(values, capacity); 124 } 125 126 MapBase::operator=(copy); 127 capacity = copy.capacity; 128 if (capacity == 0) return *this; 129 values = allocator.allocate(capacity); 130 } 132 131 133 132 for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { … … 143 142 template <typename TT> 144 143 ArrayMap& operator=(const ArrayMap<MapRegistry, TT>& copy) { 145 if (capacity != 0) { 146 MapBase::destroy(); 147 allocator.deallocate(values, capacity); 148 } 149 150 MapBase::operator=(copy); 151 152 capacity = copy.capacity; 153 if (capacity == 0) return *this; 154 values = allocator.allocate(capacity); 144 145 if (MapBase::getGraph() != copy.getGraph()) { 146 if (capacity != 0) { 147 MapBase::destroy(); 148 allocator.deallocate(values, capacity); 149 } 150 151 MapBase::operator=(copy); 152 153 capacity = copy.capacity; 154 if (capacity == 0) return *this; 155 values = allocator.allocate(capacity); 156 } 155 157 156 158 for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { -
src/hugo/default_map.h
r891 r897 38 38 typedef typename MapRegistry::Graph Graph; \ 39 39 \ 40 DefaultMap() : Parent() {} \41 40 DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \ 42 41 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \ … … 45 44 : Parent(static_cast<const Parent&>(copy)) {} \ 46 45 template <typename TT> \ 47 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \ 46 DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \ 47 : { \ 48 48 Parent::MapBase::operator= \ 49 49 (static_cast<const typename Parent::MapBase&>(copy)); \ … … 61 61 template <typename TT> \ 62 62 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \ 63 Parent::clear(); \ 64 Parent::MapBase::operator=(copy); \ 63 if (Parent::getGraph() != copy.getGraph()) { \ 64 Parent::clear(); \ 65 Parent::MapBase::operator=(copy); \ 66 Parent::construct(); \ 67 } \ 65 68 if (Parent::getGraph()) { \ 66 69 for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\ 67 Parent::add(it); \68 70 Parent::operator[](it) = copy[it]; \ 69 71 } \ -
src/hugo/extended_pair.h
r782 r897 37 37 bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 38 38 const extended_pair<T1, RA1, T2, RA2>& right) { 39 if (left.first == right.first) return left.second == right.second;40 return left.first < right.first;39 return left.first < right.first || 40 (!(right.first<left.first) && left.second < right.second); 41 41 } 42 42 -
src/hugo/full_graph.h
r880 r897 14 14 15 15 #include <hugo/map_registry.h> 16 #include <hugo/ default_map.h>16 #include <hugo/array_map.h> 17 17 18 18 #include <hugo/map_defines.h> … … 54 54 CREATE_MAP_REGISTRIES; 55 55 /// Creating node and edge maps. 56 CREATE_MAPS( DefaultMap);56 CREATE_MAPS(ArrayMap); 57 57 58 58 public: -
src/hugo/list_graph.h
r891 r897 14 14 15 15 #include <hugo/map_registry.h> 16 #include <hugo/ default_map.h>16 #include <hugo/array_map.h> 17 17 18 18 #include <hugo/sym_map.h> … … 81 81 /// \todo 82 82 /// It apears in the documentation as if it were a function definition. 83 CREATE_MAPS( DefaultMap);83 CREATE_MAPS(ArrayMap); 84 84 85 85 public: … … 446 446 CREATE_SYM_EDGE_MAP_REGISTRY; 447 447 /// Creating symmetric edge map. 448 CREATE_SYM_EDGE_MAP( DefaultMap);448 CREATE_SYM_EDGE_MAP(ArrayMap); 449 449 450 450 SymListGraph() : ListGraph() { } … … 531 531 CREATE_NODE_MAP_REGISTRY; 532 532 /// Creating node maps. 533 CREATE_NODE_MAP( DefaultMap);533 CREATE_NODE_MAP(ArrayMap); 534 534 535 535 /// Creating empty map structure for edges. … … 537 537 class EdgeMap { 538 538 public: 539 EdgeMap() {}540 539 EdgeMap(const Graph&) {} 541 540 EdgeMap(const Graph&, const Value&) {} … … 883 882 CREATE_EDGE_MAP_REGISTRY; 884 883 /// Creates edge maps. 885 CREATE_EDGE_MAP( DefaultMap);884 CREATE_EDGE_MAP(ArrayMap); 886 885 887 886 /// Imports node maps from the NodeGraphType. -
src/hugo/map_defines.h
r891 r897 41 41 public: \ 42 42 typedef DynMap<NodeMapRegistry, Value> Parent; \ 43 NodeMap() {} \44 43 NodeMap(const typename Parent::Graph& g) \ 45 44 : Parent(g, g.node_maps) {} \ … … 73 72 typedef DynMap<EdgeMapRegistry, Value> Parent; \ 74 73 \ 75 EdgeMap() {} \76 74 EdgeMap(const typename Parent::Graph& g) \ 77 75 : Parent(g, g.edge_maps) {} \ … … 119 117 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \ 120 118 \ 121 SymEdgeMap() {} \122 119 SymEdgeMap(const typename Parent::Graph& g) \ 123 120 : Parent(g, g.sym_edge_maps) {} \ … … 149 146 typedef typename From::template NodeMap<Value> Parent; \ 150 147 \ 151 NodeMap() : Parent() {} \152 148 NodeMap(const To& to) \ 153 149 : Parent(static_cast<const From&>(from)) { } \ … … 179 175 typedef typename From::template EdgeMap<Value> Parent; \ 180 176 \ 181 EdgeMap() : Parent() {} \182 177 EdgeMap(const To& to) \ 183 178 : Parent(static_cast<const From&>(from)) { } \ -
src/hugo/smart_graph.h
r891 r897 13 13 #include <hugo/invalid.h> 14 14 15 #include <hugo/ default_map.h>15 #include <hugo/array_map.h> 16 16 #include <hugo/sym_map.h> 17 17 … … 77 77 CREATE_MAP_REGISTRIES; 78 78 /// Creating node and edge maps. 79 CREATE_MAPS( DefaultMap);79 CREATE_MAPS(ArrayMap); 80 80 81 81 public: … … 321 321 CREATE_SYM_EDGE_MAP_REGISTRY; 322 322 /// Creating symmetric edge map. 323 CREATE_SYM_EDGE_MAP( DefaultMap);323 CREATE_SYM_EDGE_MAP(ArrayMap); 324 324 325 325 -
src/hugo/sym_map.h
r891 r897 86 86 87 87 88 /** Default constructor for the map.89 */90 SymMap() : MapImpl() {}91 92 88 /** Graph and Registry initialized map constructor. 93 89 */ -
src/hugo/vector_map.h
r891 r897 70 70 typedef typename Container::const_pointer ConstPointerType; 71 71 72 /** Default constructor for the map.73 */74 VectorMap() {}75 76 72 /** Graph and Registry initialized map constructor. 77 73 */ … … 99 95 template <typename TT> 100 96 VectorMap& operator=(const VectorMap<MapRegistry, TT>& c) { 101 container.resize(c.container.size()); 102 MapBase::operator=(c); 97 if (MapBase::getGraph() != c.getGraph()) { 98 MapBase::operator=(c); 99 container.resize(c.container.size()); 100 } 103 101 for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { 104 102 int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
Note: See TracChangeset
for help on using the changeset viewer.