[Lemon-commits] [lemon_svn] deba: r1205 - hugo/trunk/src/hugo

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:43:52 CET 2006


Author: deba
Date: Wed Sep 22 10:04:31 2004
New Revision: 1205

Modified:
   hugo/trunk/src/hugo/array_map.h
   hugo/trunk/src/hugo/default_map.h
   hugo/trunk/src/hugo/extended_pair.h
   hugo/trunk/src/hugo/full_graph.h
   hugo/trunk/src/hugo/list_graph.h
   hugo/trunk/src/hugo/map_defines.h
   hugo/trunk/src/hugo/smart_graph.h
   hugo/trunk/src/hugo/sym_map.h
   hugo/trunk/src/hugo/vector_map.h

Log:
The default constructors are removed from the maps.
The ArrayMap is the map structure of the graphs.


Modified: hugo/trunk/src/hugo/array_map.h
==============================================================================
--- hugo/trunk/src/hugo/array_map.h	(original)
+++ hugo/trunk/src/hugo/array_map.h	Wed Sep 22 10:04:31 2004
@@ -29,6 +29,8 @@
 
   template <typename MapRegistry, typename Value> 
   class ArrayMap : public MapRegistry::MapBase {
+
+    template <typename MR, typename V> friend class ArrayMap;
 		
   public:
 		
@@ -63,10 +65,6 @@
     typedef std::allocator<Value> 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 (&copy == 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<Graph, KeyIt>::id(*MapBase::getGraph(), it);
 	allocator.construct(&(values[id]), copy.values[id]);
@@ -142,16 +141,19 @@
      */
     template <typename TT>
     ArrayMap& operator=(const ArrayMap<MapRegistry, TT>& copy) {
-      if (capacity != 0) {
-	MapBase::destroy();
-	allocator.deallocate(values, capacity);
-      }
 
-      MapBase::operator=(copy);
+      if (MapBase::getGraph() != copy.getGraph()) {
+	if (capacity != 0) {
+	  MapBase::destroy();
+	  allocator.deallocate(values, capacity);
+	}
 
-      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<Graph, KeyIt>::id(*MapBase::getGraph(), it);

Modified: hugo/trunk/src/hugo/default_map.h
==============================================================================
--- hugo/trunk/src/hugo/default_map.h	(original)
+++ hugo/trunk/src/hugo/default_map.h	Wed Sep 22 10:04:31 2004
@@ -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<const Parent&>(copy)) {} \
 template <typename TT> \
-DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \
+DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \
+  : { \
   Parent::MapBase::operator= \
     (static_cast<const typename Parent::MapBase&>(copy)); \
   if (Parent::getGraph()) { \
@@ -60,11 +60,13 @@
 } \
 template <typename TT> \
 DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& 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]; \
     } \
   } \

Modified: hugo/trunk/src/hugo/extended_pair.h
==============================================================================
--- hugo/trunk/src/hugo/extended_pair.h	(original)
+++ hugo/trunk/src/hugo/extended_pair.h	Wed Sep 22 10:04:31 2004
@@ -36,8 +36,8 @@
 	  typename LA1, typename LA2, typename RA1, typename RA2>
 bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 
 		const extended_pair<T1, RA1, T2, RA2>& right) {
-  if (left.first == right.first) return left.second == right.second;
-  return left.first < right.first;
+  return left.first < right.first || 
+           (!(right.first<left.first) && left.second < right.second);
 }
 
 template <typename T1, typename T2, 

Modified: hugo/trunk/src/hugo/full_graph.h
==============================================================================
--- hugo/trunk/src/hugo/full_graph.h	(original)
+++ hugo/trunk/src/hugo/full_graph.h	Wed Sep 22 10:04:31 2004
@@ -13,7 +13,7 @@
 #include <hugo/invalid.h>
 
 #include <hugo/map_registry.h>
-#include <hugo/default_map.h>
+#include <hugo/array_map.h>
 
 #include <hugo/map_defines.h>
 
@@ -53,7 +53,7 @@
     /// Creating map registries.
     CREATE_MAP_REGISTRIES;
     /// Creating node and edge maps.
-    CREATE_MAPS(DefaultMap);
+    CREATE_MAPS(ArrayMap);
     
   public:
 

Modified: hugo/trunk/src/hugo/list_graph.h
==============================================================================
--- hugo/trunk/src/hugo/list_graph.h	(original)
+++ hugo/trunk/src/hugo/list_graph.h	Wed Sep 22 10:04:31 2004
@@ -13,7 +13,7 @@
 #include <hugo/invalid.h>
 
 #include <hugo/map_registry.h>
-#include <hugo/default_map.h>
+#include <hugo/array_map.h>
 
 #include <hugo/sym_map.h>
 
@@ -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 <typename Value>
     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);

Modified: hugo/trunk/src/hugo/map_defines.h
==============================================================================
--- hugo/trunk/src/hugo/map_defines.h	(original)
+++ hugo/trunk/src/hugo/map_defines.h	Wed Sep 22 10:04:31 2004
@@ -40,7 +40,6 @@
 class NodeMap : public DynMap<NodeMapRegistry, Value> { \
 public: \
 typedef DynMap<NodeMapRegistry, Value> 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<EdgeMapRegistry, Value> 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<DynMap, SymEdgeMapRegistry, Value> 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<Value> Parent; \
 \
-NodeMap() : Parent() {} \
 NodeMap(const To& to) \
   : Parent(static_cast<const From&>(from)) { } \
 NodeMap(const To& to, const Value& value) \
@@ -178,7 +174,6 @@
 public: \
 typedef typename From::template EdgeMap<Value> Parent; \
 \
-EdgeMap() : Parent() {} \
 EdgeMap(const To& to) \
   : Parent(static_cast<const From&>(from)) { } \
 EdgeMap(const To& to, const Value& value) \

Modified: hugo/trunk/src/hugo/smart_graph.h
==============================================================================
--- hugo/trunk/src/hugo/smart_graph.h	(original)
+++ hugo/trunk/src/hugo/smart_graph.h	Wed Sep 22 10:04:31 2004
@@ -12,7 +12,7 @@
 
 #include <hugo/invalid.h>
 
-#include <hugo/default_map.h>
+#include <hugo/array_map.h>
 #include <hugo/sym_map.h>
 
 #include <hugo/map_registry.h>
@@ -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() { }

Modified: hugo/trunk/src/hugo/sym_map.h
==============================================================================
--- hugo/trunk/src/hugo/sym_map.h	(original)
+++ hugo/trunk/src/hugo/sym_map.h	Wed Sep 22 10:04:31 2004
@@ -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) {}

Modified: hugo/trunk/src/hugo/vector_map.h
==============================================================================
--- hugo/trunk/src/hugo/vector_map.h	(original)
+++ hugo/trunk/src/hugo/vector_map.h	Wed Sep 22 10:04:31 2004
@@ -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 <typename TT>
     VectorMap& operator=(const VectorMap<MapRegistry, TT>& 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<Graph, KeyIt>::id(*MapBase::getGraph(), it);
 	container[id] = c.container[id];



More information about the Lemon-commits mailing list