# HG changeset patch # User deba # Date 1095840271 0 # Node ID ef09eee53b09c8d6172f372a903eb68502e2355e # Parent 3a98a1aa5a8f4869b8c4559b333d176ed4cf0c71 The default constructors are removed from the maps. The ArrayMap is the map structure of the graphs. diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/array_map.h --- a/src/hugo/array_map.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/array_map.h Wed Sep 22 08:04:31 2004 +0000 @@ -29,6 +29,8 @@ template class ArrayMap : public MapRegistry::MapBase { + + template friend class ArrayMap; public: @@ -63,10 +65,6 @@ typedef std::allocator Allocator; - /** Default constructor for the map. - */ - ArrayMap() : capacity(0), values(0) {} - /** Graph and Registry initialized map constructor. */ ArrayMap(const Graph& g, MapRegistry& r) : MapBase(g, r) { @@ -118,18 +116,19 @@ */ ArrayMap& operator=(const ArrayMap& copy) { if (© == this) return *this; + + if (MapBase::getGraph() != copy.getGraph()) { + if (capacity != 0) { + MapBase::destroy(); + allocator.deallocate(values, capacity); + } - if (capacity != 0) { - MapBase::destroy(); - allocator.deallocate(values, capacity); + MapBase::operator=(copy); + capacity = copy.capacity; + if (capacity == 0) return *this; + values = allocator.allocate(capacity); } - MapBase::operator=(copy); - - capacity = copy.capacity; - if (capacity == 0) return *this; - values = allocator.allocate(capacity); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { int id = KeyInfo::id(*MapBase::getGraph(), it); allocator.construct(&(values[id]), copy.values[id]); @@ -142,17 +141,20 @@ */ template ArrayMap& operator=(const ArrayMap& copy) { - if (capacity != 0) { - MapBase::destroy(); - allocator.deallocate(values, capacity); + + if (MapBase::getGraph() != copy.getGraph()) { + if (capacity != 0) { + MapBase::destroy(); + allocator.deallocate(values, capacity); + } + + MapBase::operator=(copy); + + capacity = copy.capacity; + if (capacity == 0) return *this; + values = allocator.allocate(capacity); } - MapBase::operator=(copy); - - capacity = copy.capacity; - if (capacity == 0) return *this; - values = allocator.allocate(capacity); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { int id = KeyInfo::id(*MapBase::getGraph(), it); allocator.construct(&(values[id]), copy.values[id]); diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/default_map.h --- a/src/hugo/default_map.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/default_map.h Wed Sep 22 08:04:31 2004 +0000 @@ -37,14 +37,14 @@ \ typedef typename MapRegistry::Graph Graph; \ \ -DefaultMap() : Parent() {} \ DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \ DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \ : Parent(g, r, v) {} \ DefaultMap(const DefaultMap& copy) \ : Parent(static_cast(copy)) {} \ template \ -DefaultMap(const DefaultMap& copy) { \ +DefaultMap(const DefaultMap& copy) \ + : { \ Parent::MapBase::operator= \ (static_cast(copy)); \ if (Parent::getGraph()) { \ @@ -60,11 +60,13 @@ } \ template \ DefaultMap& operator=(const DefaultMap& copy) { \ - Parent::clear(); \ - Parent::MapBase::operator=(copy); \ + if (Parent::getGraph() != copy.getGraph()) { \ + Parent::clear(); \ + Parent::MapBase::operator=(copy); \ + Parent::construct(); \ + } \ if (Parent::getGraph()) { \ for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\ - Parent::add(it); \ Parent::operator[](it) = copy[it]; \ } \ } \ diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/extended_pair.h --- a/src/hugo/extended_pair.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/extended_pair.h Wed Sep 22 08:04:31 2004 +0000 @@ -36,8 +36,8 @@ typename LA1, typename LA2, typename RA1, typename RA2> bool operator<(const extended_pair& left, const extended_pair& right) { - if (left.first == right.first) return left.second == right.second; - return left.first < right.first; + return left.first < right.first || + (!(right.first #include -#include +#include #include @@ -53,7 +53,7 @@ /// Creating map registries. CREATE_MAP_REGISTRIES; /// Creating node and edge maps. - CREATE_MAPS(DefaultMap); + CREATE_MAPS(ArrayMap); public: diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/list_graph.h --- a/src/hugo/list_graph.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/list_graph.h Wed Sep 22 08:04:31 2004 +0000 @@ -13,7 +13,7 @@ #include #include -#include +#include #include @@ -80,7 +80,7 @@ /// \todo /// It apears in the documentation as if it were a function definition. - CREATE_MAPS(DefaultMap); + CREATE_MAPS(ArrayMap); public: @@ -445,7 +445,7 @@ /// Creating symmetric map registry. CREATE_SYM_EDGE_MAP_REGISTRY; /// Creating symmetric edge map. - CREATE_SYM_EDGE_MAP(DefaultMap); + CREATE_SYM_EDGE_MAP(ArrayMap); SymListGraph() : ListGraph() { } SymListGraph(const ListGraph &_g) : ListGraph(_g) { } @@ -530,13 +530,12 @@ /// Creating node map registry. CREATE_NODE_MAP_REGISTRY; /// Creating node maps. - CREATE_NODE_MAP(DefaultMap); + CREATE_NODE_MAP(ArrayMap); /// Creating empty map structure for edges. template class EdgeMap { public: - EdgeMap() {} EdgeMap(const Graph&) {} EdgeMap(const Graph&, const Value&) {} @@ -882,7 +881,7 @@ /// Creates edge map registry. CREATE_EDGE_MAP_REGISTRY; /// Creates edge maps. - CREATE_EDGE_MAP(DefaultMap); + CREATE_EDGE_MAP(ArrayMap); /// Imports node maps from the NodeGraphType. IMPORT_NODE_MAP(NodeGraphType, graph.G, EdgeSet, graph); diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/map_defines.h --- a/src/hugo/map_defines.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/map_defines.h Wed Sep 22 08:04:31 2004 +0000 @@ -40,7 +40,6 @@ class NodeMap : public DynMap { \ public: \ typedef DynMap Parent; \ -NodeMap() {} \ NodeMap(const typename Parent::Graph& g) \ : Parent(g, g.node_maps) {} \ NodeMap(const typename Parent::Graph& g, const Value& v) \ @@ -72,7 +71,6 @@ public: \ typedef DynMap Parent; \ \ -EdgeMap() {} \ EdgeMap(const typename Parent::Graph& g) \ : Parent(g, g.edge_maps) {} \ EdgeMap(const typename Parent::Graph& g, const Value& v) \ @@ -118,7 +116,6 @@ public: \ typedef SymMap Parent; \ \ -SymEdgeMap() {} \ SymEdgeMap(const typename Parent::Graph& g) \ : Parent(g, g.sym_edge_maps) {} \ SymEdgeMap(const typename Parent::Graph& g, const Value& v) \ @@ -148,7 +145,6 @@ public: \ typedef typename From::template NodeMap Parent; \ \ -NodeMap() : Parent() {} \ NodeMap(const To& to) \ : Parent(static_cast(from)) { } \ NodeMap(const To& to, const Value& value) \ @@ -178,7 +174,6 @@ public: \ typedef typename From::template EdgeMap Parent; \ \ -EdgeMap() : Parent() {} \ EdgeMap(const To& to) \ : Parent(static_cast(from)) { } \ EdgeMap(const To& to, const Value& value) \ diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/smart_graph.h --- a/src/hugo/smart_graph.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/smart_graph.h Wed Sep 22 08:04:31 2004 +0000 @@ -12,7 +12,7 @@ #include -#include +#include #include #include @@ -76,7 +76,7 @@ /// Creating map registries. CREATE_MAP_REGISTRIES; /// Creating node and edge maps. - CREATE_MAPS(DefaultMap); + CREATE_MAPS(ArrayMap); public: @@ -320,7 +320,7 @@ /// Creating symmetric map registry. CREATE_SYM_EDGE_MAP_REGISTRY; /// Creating symmetric edge map. - CREATE_SYM_EDGE_MAP(DefaultMap); + CREATE_SYM_EDGE_MAP(ArrayMap); SymSmartGraph() : SmartGraph() { } diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/sym_map.h --- a/src/hugo/sym_map.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/sym_map.h Wed Sep 22 08:04:31 2004 +0000 @@ -85,10 +85,6 @@ public: - /** Default constructor for the map. - */ - SymMap() : MapImpl() {} - /** Graph and Registry initialized map constructor. */ SymMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} diff -r 3a98a1aa5a8f -r ef09eee53b09 src/hugo/vector_map.h --- a/src/hugo/vector_map.h Wed Sep 22 07:32:57 2004 +0000 +++ b/src/hugo/vector_map.h Wed Sep 22 08:04:31 2004 +0000 @@ -69,10 +69,6 @@ /// The pointer type of the map; typedef typename Container::const_pointer ConstPointerType; - /** Default constructor for the map. - */ - VectorMap() {} - /** Graph and Registry initialized map constructor. */ VectorMap(const Graph& g, MapRegistry& r) @@ -98,8 +94,10 @@ */ template VectorMap& operator=(const VectorMap& c) { - container.resize(c.container.size()); - MapBase::operator=(c); + if (MapBase::getGraph() != c.getGraph()) { + MapBase::operator=(c); + container.resize(c.container.size()); + } for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { int id = KeyInfo::id(*MapBase::getGraph(), it); container[id] = c.container[id];