The default constructors are removed from the maps.
The ArrayMap is the map structure of the graphs.
1.1 --- a/src/hugo/array_map.h Wed Sep 22 07:32:57 2004 +0000
1.2 +++ b/src/hugo/array_map.h Wed Sep 22 08:04:31 2004 +0000
1.3 @@ -29,6 +29,8 @@
1.4
1.5 template <typename MapRegistry, typename Value>
1.6 class ArrayMap : public MapRegistry::MapBase {
1.7 +
1.8 + template <typename MR, typename V> friend class ArrayMap;
1.9
1.10 public:
1.11
1.12 @@ -63,10 +65,6 @@
1.13 typedef std::allocator<Value> Allocator;
1.14
1.15
1.16 - /** Default constructor for the map.
1.17 - */
1.18 - ArrayMap() : capacity(0), values(0) {}
1.19 -
1.20 /** Graph and Registry initialized map constructor.
1.21 */
1.22 ArrayMap(const Graph& g, MapRegistry& r) : MapBase(g, r) {
1.23 @@ -118,18 +116,19 @@
1.24 */
1.25 ArrayMap& operator=(const ArrayMap& copy) {
1.26 if (© == this) return *this;
1.27 +
1.28 + if (MapBase::getGraph() != copy.getGraph()) {
1.29 + if (capacity != 0) {
1.30 + MapBase::destroy();
1.31 + allocator.deallocate(values, capacity);
1.32 + }
1.33
1.34 - if (capacity != 0) {
1.35 - MapBase::destroy();
1.36 - allocator.deallocate(values, capacity);
1.37 + MapBase::operator=(copy);
1.38 + capacity = copy.capacity;
1.39 + if (capacity == 0) return *this;
1.40 + values = allocator.allocate(capacity);
1.41 }
1.42
1.43 - MapBase::operator=(copy);
1.44 -
1.45 - capacity = copy.capacity;
1.46 - if (capacity == 0) return *this;
1.47 - values = allocator.allocate(capacity);
1.48 -
1.49 for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
1.50 int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
1.51 allocator.construct(&(values[id]), copy.values[id]);
1.52 @@ -142,17 +141,20 @@
1.53 */
1.54 template <typename TT>
1.55 ArrayMap& operator=(const ArrayMap<MapRegistry, TT>& copy) {
1.56 - if (capacity != 0) {
1.57 - MapBase::destroy();
1.58 - allocator.deallocate(values, capacity);
1.59 +
1.60 + if (MapBase::getGraph() != copy.getGraph()) {
1.61 + if (capacity != 0) {
1.62 + MapBase::destroy();
1.63 + allocator.deallocate(values, capacity);
1.64 + }
1.65 +
1.66 + MapBase::operator=(copy);
1.67 +
1.68 + capacity = copy.capacity;
1.69 + if (capacity == 0) return *this;
1.70 + values = allocator.allocate(capacity);
1.71 }
1.72
1.73 - MapBase::operator=(copy);
1.74 -
1.75 - capacity = copy.capacity;
1.76 - if (capacity == 0) return *this;
1.77 - values = allocator.allocate(capacity);
1.78 -
1.79 for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
1.80 int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
1.81 allocator.construct(&(values[id]), copy.values[id]);
2.1 --- a/src/hugo/default_map.h Wed Sep 22 07:32:57 2004 +0000
2.2 +++ b/src/hugo/default_map.h Wed Sep 22 08:04:31 2004 +0000
2.3 @@ -37,14 +37,14 @@
2.4 \
2.5 typedef typename MapRegistry::Graph Graph; \
2.6 \
2.7 -DefaultMap() : Parent() {} \
2.8 DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
2.9 DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
2.10 : Parent(g, r, v) {} \
2.11 DefaultMap(const DefaultMap& copy) \
2.12 : Parent(static_cast<const Parent&>(copy)) {} \
2.13 template <typename TT> \
2.14 -DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \
2.15 +DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \
2.16 + : { \
2.17 Parent::MapBase::operator= \
2.18 (static_cast<const typename Parent::MapBase&>(copy)); \
2.19 if (Parent::getGraph()) { \
2.20 @@ -60,11 +60,13 @@
2.21 } \
2.22 template <typename TT> \
2.23 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
2.24 - Parent::clear(); \
2.25 - Parent::MapBase::operator=(copy); \
2.26 + if (Parent::getGraph() != copy.getGraph()) { \
2.27 + Parent::clear(); \
2.28 + Parent::MapBase::operator=(copy); \
2.29 + Parent::construct(); \
2.30 + } \
2.31 if (Parent::getGraph()) { \
2.32 for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
2.33 - Parent::add(it); \
2.34 Parent::operator[](it) = copy[it]; \
2.35 } \
2.36 } \
3.1 --- a/src/hugo/extended_pair.h Wed Sep 22 07:32:57 2004 +0000
3.2 +++ b/src/hugo/extended_pair.h Wed Sep 22 08:04:31 2004 +0000
3.3 @@ -36,8 +36,8 @@
3.4 typename LA1, typename LA2, typename RA1, typename RA2>
3.5 bool operator<(const extended_pair<T1, LA1, T2, LA2>& left,
3.6 const extended_pair<T1, RA1, T2, RA2>& right) {
3.7 - if (left.first == right.first) return left.second == right.second;
3.8 - return left.first < right.first;
3.9 + return left.first < right.first ||
3.10 + (!(right.first<left.first) && left.second < right.second);
3.11 }
3.12
3.13 template <typename T1, typename T2,
4.1 --- a/src/hugo/full_graph.h Wed Sep 22 07:32:57 2004 +0000
4.2 +++ b/src/hugo/full_graph.h Wed Sep 22 08:04:31 2004 +0000
4.3 @@ -13,7 +13,7 @@
4.4 #include <hugo/invalid.h>
4.5
4.6 #include <hugo/map_registry.h>
4.7 -#include <hugo/default_map.h>
4.8 +#include <hugo/array_map.h>
4.9
4.10 #include <hugo/map_defines.h>
4.11
4.12 @@ -53,7 +53,7 @@
4.13 /// Creating map registries.
4.14 CREATE_MAP_REGISTRIES;
4.15 /// Creating node and edge maps.
4.16 - CREATE_MAPS(DefaultMap);
4.17 + CREATE_MAPS(ArrayMap);
4.18
4.19 public:
4.20
5.1 --- a/src/hugo/list_graph.h Wed Sep 22 07:32:57 2004 +0000
5.2 +++ b/src/hugo/list_graph.h Wed Sep 22 08:04:31 2004 +0000
5.3 @@ -13,7 +13,7 @@
5.4 #include <hugo/invalid.h>
5.5
5.6 #include <hugo/map_registry.h>
5.7 -#include <hugo/default_map.h>
5.8 +#include <hugo/array_map.h>
5.9
5.10 #include <hugo/sym_map.h>
5.11
5.12 @@ -80,7 +80,7 @@
5.13
5.14 /// \todo
5.15 /// It apears in the documentation as if it were a function definition.
5.16 - CREATE_MAPS(DefaultMap);
5.17 + CREATE_MAPS(ArrayMap);
5.18
5.19 public:
5.20
5.21 @@ -445,7 +445,7 @@
5.22 /// Creating symmetric map registry.
5.23 CREATE_SYM_EDGE_MAP_REGISTRY;
5.24 /// Creating symmetric edge map.
5.25 - CREATE_SYM_EDGE_MAP(DefaultMap);
5.26 + CREATE_SYM_EDGE_MAP(ArrayMap);
5.27
5.28 SymListGraph() : ListGraph() { }
5.29 SymListGraph(const ListGraph &_g) : ListGraph(_g) { }
5.30 @@ -530,13 +530,12 @@
5.31 /// Creating node map registry.
5.32 CREATE_NODE_MAP_REGISTRY;
5.33 /// Creating node maps.
5.34 - CREATE_NODE_MAP(DefaultMap);
5.35 + CREATE_NODE_MAP(ArrayMap);
5.36
5.37 /// Creating empty map structure for edges.
5.38 template <typename Value>
5.39 class EdgeMap {
5.40 public:
5.41 - EdgeMap() {}
5.42 EdgeMap(const Graph&) {}
5.43 EdgeMap(const Graph&, const Value&) {}
5.44
5.45 @@ -882,7 +881,7 @@
5.46 /// Creates edge map registry.
5.47 CREATE_EDGE_MAP_REGISTRY;
5.48 /// Creates edge maps.
5.49 - CREATE_EDGE_MAP(DefaultMap);
5.50 + CREATE_EDGE_MAP(ArrayMap);
5.51
5.52 /// Imports node maps from the NodeGraphType.
5.53 IMPORT_NODE_MAP(NodeGraphType, graph.G, EdgeSet, graph);
6.1 --- a/src/hugo/map_defines.h Wed Sep 22 07:32:57 2004 +0000
6.2 +++ b/src/hugo/map_defines.h Wed Sep 22 08:04:31 2004 +0000
6.3 @@ -40,7 +40,6 @@
6.4 class NodeMap : public DynMap<NodeMapRegistry, Value> { \
6.5 public: \
6.6 typedef DynMap<NodeMapRegistry, Value> Parent; \
6.7 -NodeMap() {} \
6.8 NodeMap(const typename Parent::Graph& g) \
6.9 : Parent(g, g.node_maps) {} \
6.10 NodeMap(const typename Parent::Graph& g, const Value& v) \
6.11 @@ -72,7 +71,6 @@
6.12 public: \
6.13 typedef DynMap<EdgeMapRegistry, Value> Parent; \
6.14 \
6.15 -EdgeMap() {} \
6.16 EdgeMap(const typename Parent::Graph& g) \
6.17 : Parent(g, g.edge_maps) {} \
6.18 EdgeMap(const typename Parent::Graph& g, const Value& v) \
6.19 @@ -118,7 +116,6 @@
6.20 public: \
6.21 typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
6.22 \
6.23 -SymEdgeMap() {} \
6.24 SymEdgeMap(const typename Parent::Graph& g) \
6.25 : Parent(g, g.sym_edge_maps) {} \
6.26 SymEdgeMap(const typename Parent::Graph& g, const Value& v) \
6.27 @@ -148,7 +145,6 @@
6.28 public: \
6.29 typedef typename From::template NodeMap<Value> Parent; \
6.30 \
6.31 -NodeMap() : Parent() {} \
6.32 NodeMap(const To& to) \
6.33 : Parent(static_cast<const From&>(from)) { } \
6.34 NodeMap(const To& to, const Value& value) \
6.35 @@ -178,7 +174,6 @@
6.36 public: \
6.37 typedef typename From::template EdgeMap<Value> Parent; \
6.38 \
6.39 -EdgeMap() : Parent() {} \
6.40 EdgeMap(const To& to) \
6.41 : Parent(static_cast<const From&>(from)) { } \
6.42 EdgeMap(const To& to, const Value& value) \
7.1 --- a/src/hugo/smart_graph.h Wed Sep 22 07:32:57 2004 +0000
7.2 +++ b/src/hugo/smart_graph.h Wed Sep 22 08:04:31 2004 +0000
7.3 @@ -12,7 +12,7 @@
7.4
7.5 #include <hugo/invalid.h>
7.6
7.7 -#include <hugo/default_map.h>
7.8 +#include <hugo/array_map.h>
7.9 #include <hugo/sym_map.h>
7.10
7.11 #include <hugo/map_registry.h>
7.12 @@ -76,7 +76,7 @@
7.13 /// Creating map registries.
7.14 CREATE_MAP_REGISTRIES;
7.15 /// Creating node and edge maps.
7.16 - CREATE_MAPS(DefaultMap);
7.17 + CREATE_MAPS(ArrayMap);
7.18
7.19 public:
7.20
7.21 @@ -320,7 +320,7 @@
7.22 /// Creating symmetric map registry.
7.23 CREATE_SYM_EDGE_MAP_REGISTRY;
7.24 /// Creating symmetric edge map.
7.25 - CREATE_SYM_EDGE_MAP(DefaultMap);
7.26 + CREATE_SYM_EDGE_MAP(ArrayMap);
7.27
7.28
7.29 SymSmartGraph() : SmartGraph() { }
8.1 --- a/src/hugo/sym_map.h Wed Sep 22 07:32:57 2004 +0000
8.2 +++ b/src/hugo/sym_map.h Wed Sep 22 08:04:31 2004 +0000
8.3 @@ -85,10 +85,6 @@
8.4 public:
8.5
8.6
8.7 - /** Default constructor for the map.
8.8 - */
8.9 - SymMap() : MapImpl() {}
8.10 -
8.11 /** Graph and Registry initialized map constructor.
8.12 */
8.13 SymMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
9.1 --- a/src/hugo/vector_map.h Wed Sep 22 07:32:57 2004 +0000
9.2 +++ b/src/hugo/vector_map.h Wed Sep 22 08:04:31 2004 +0000
9.3 @@ -69,10 +69,6 @@
9.4 /// The pointer type of the map;
9.5 typedef typename Container::const_pointer ConstPointerType;
9.6
9.7 - /** Default constructor for the map.
9.8 - */
9.9 - VectorMap() {}
9.10 -
9.11 /** Graph and Registry initialized map constructor.
9.12 */
9.13 VectorMap(const Graph& g, MapRegistry& r)
9.14 @@ -98,8 +94,10 @@
9.15 */
9.16 template <typename TT>
9.17 VectorMap& operator=(const VectorMap<MapRegistry, TT>& c) {
9.18 - container.resize(c.container.size());
9.19 - MapBase::operator=(c);
9.20 + if (MapBase::getGraph() != c.getGraph()) {
9.21 + MapBase::operator=(c);
9.22 + container.resize(c.container.size());
9.23 + }
9.24 for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
9.25 int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
9.26 container[id] = c.container[id];