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

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


Author: deba
Date: Fri Sep  3 17:32:03 2004
New Revision: 1093

Modified:
   hugo/trunk/src/hugo/array_map_factory.h
   hugo/trunk/src/hugo/default_map_factory.h
   hugo/trunk/src/hugo/vector_map_factory.h

Log:


Modified: hugo/trunk/src/hugo/array_map_factory.h
==============================================================================
--- hugo/trunk/src/hugo/array_map_factory.h	(original)
+++ hugo/trunk/src/hugo/array_map_factory.h	Fri Sep  3 17:32:03 2004
@@ -12,33 +12,68 @@
 ///their elements dynamically.
 
 namespace hugo {
-	
+
+
 /// \addtogroup graphmapfactory
 /// @{
+	
+  /** The ArrayMapFactory template class is a factory class
+   *  to create maps for the edge and nodes. This map factory
+   *  uses the allocators to implement the container function.
+   *
+   *  The template parameter is the MapRegistry that the maps
+   *  will belong to.
+   */
 
-  ///.
-  template <typename MapRegistry> class ArrayMapFactory {
+  template <typename MapRegistry> 
+  class ArrayMapFactory {
 		
   public:
 		
+    /// The graph type of the maps. 
     typedef typename MapRegistry::Graph Graph;
+    /// The key type of the maps.
     typedef typename MapRegistry::KeyType KeyType;
+    /// The iterator to iterate on the keys.
     typedef typename MapRegistry::KeyIt KeyIt;
 
+    /// The MapBase of the Map which imlements the core regisitry function.
     typedef typename MapRegistry::MapBase MapBase;
 		
+    /** The template Map type.
+     */
     template <typename V, typename A = std::allocator<V> > 
     class Map : public MapBase {
     
       public:
 
-      typedef V Value;
+      /// The value type of the map.
       typedef V ValueType;
+
+      /// The value type of the map.
+      typedef V Value;
+      /// The reference type of the map;
+      typedef Value& Reference;
+      /// The pointer type of the map;
+      typedef Value* Pointer;
+
+      /// The const value type of the map.
+      typedef const Value ConstValue;
+      /// The const reference type of the map;
+      typedef const Value& ConstReference;
+      /// The pointer type of the map;
+      typedef const Value* ConstPointer;
+
+
       typedef A Allocator;
 
 	
+      /** Default constructor for the map.
+       */
       Map() : values(0), capacity(0) {}
 			
+      /** Graph and Registry initialized map constructor.
+       */
       Map(const Graph& g, MapRegistry& r) : MapBase(g, r) {
 	allocate_memory();
 	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
@@ -47,6 +82,8 @@
 	}								
       }
 
+      /** Constructor to use default value to initialize the map. 
+       */
       Map(const Graph& g, MapRegistry& r, const Value& v) : MapBase(g, r) {
 	allocate_memory();
 	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
@@ -55,6 +92,8 @@
 	}								
       }
 
+      /** Constructor to copy a map of the same map type.
+       */
       Map(const Map& copy) : MapBase(*copy.graph, *copy.registry) {
 	capacity = copy.capacity;
 	if (capacity == 0) return;
@@ -65,6 +104,8 @@
 	}
       }
 
+      /** Constructor to copy a map of an other map type.
+       */
       template <typename CMap> Map(const CMap& copy) 
 	: MapBase(copy), capacity(0), values(0) {
 	if (MapBase::getGraph()) {
@@ -75,6 +116,8 @@
 	}
       }
 
+      /** Assign operator to copy a map of the same map type.
+       */
       Map& operator=(const Map& copy) {
 	if (&copy == this) return *this;
 	if (capacity != 0) {
@@ -91,6 +134,8 @@
 	return *this;
       }
 
+      /** Assign operator to copy a map an other map type.
+       */
       template <typename CMap> Map& operator=(const CMap& copy) {
 	if (MapBase::getGraph()) {
 	  MapBase::destroy();
@@ -105,6 +150,8 @@
 	return *this;
       }
 				
+      /** The destructor of the map.
+       */
       virtual ~Map() {
 	if (capacity != 0) {
 	  MapBase::destroy();
@@ -113,26 +160,34 @@
       }
 	
 	
+      /**
+       * The subscript operator. The map can be subscripted by the
+       * actual keys of the graph. 
+       */
       Value& operator[](const KeyType& key) {
 	int id = MapBase::getGraph()->id(key);
 	return values[id];
       } 
 		
+      /**
+       * The const subscript operator. The map can be subscripted by the
+       * actual keys of the graph. 
+       */
       const Value& operator[](const KeyType& key) const {
 	int id = MapBase::getGraph()->id(key);
 	return values[id];
       }
 	
-      const Value& get(const KeyType& key) const {
-	int id = MapBase::getGraph()->id(key);
-	return values[id];
-      } 
-		
+      /** Setter function of the map. Equivalent with map[key] = val.
+       *  This is a compatibility feature with the not dereferable maps.
+       */
       void set(const KeyType& key, const Value& val) {
 	int id = MapBase::getGraph()->id(key);
 	values[id] = val;
       }
 		
+      /** Add a new key to the map. It called by the map registry.
+       */
       void add(const KeyType& key) {
 	int id = MapBase::getGraph()->id(key);
 	if (id >= capacity) {
@@ -155,11 +210,15 @@
 	allocator.construct(&(values[id]), Value());
       }
 		
+      /** Erase a key from the map. It called by the map registry.
+       */
       void erase(const KeyType& key) {
 	int id = MapBase::getGraph()->id(key);
 	allocator.destroy(&(values[id]));
       }
 
+      /** Clear the data structure.
+       */
       void clear() {	
 	if (capacity != 0) {
 	  MapBase::destroy();
@@ -168,6 +227,9 @@
 	}
       }
 	
+      /** Compatible iterator with the stl maps' iterators.
+       *  It iterates on pairs of a key and a value.
+       */
       class iterator {
 	friend class Map;
 	friend class const_iterator;
@@ -371,9 +433,8 @@
       Allocator allocator;
     };		
   };
-  
+
 /// @}
-  
 
 }
 

Modified: hugo/trunk/src/hugo/default_map_factory.h
==============================================================================
--- hugo/trunk/src/hugo/default_map_factory.h	(original)
+++ hugo/trunk/src/hugo/default_map_factory.h	Fri Sep  3 17:32:03 2004
@@ -6,8 +6,16 @@
 #include <hugo/array_map_factory.h>
 #include <hugo/vector_map_factory.h>
 
+///\ingroup graphmapfactory
+///\file
+///\brief Graph maps that construates and destruates
+///their elements dynamically.
+
 namespace hugo {
 
+/// \addtogroup graphmapfactory
+/// @{
+
 #define DEFAULT_MAP_BODY(Factory, Val) \
   { \
     typedef typename Factory<MapRegistry>::template Map<Val> MapImpl; \
@@ -15,7 +23,7 @@
   public: \
   \
     typedef typename MapRegistry::Graph Graph; \
-    typedef typename MapRegistry::Key Key; \
+    typedef typename MapRegistry::KeyType KeyType; \
     typedef typename MapRegistry::KeyIt KeyIt; \
     typedef Val Value; \
   \
@@ -95,17 +103,33 @@
     : public VectorMapFactory<MapRegistry>::template Map<Type*> 
   DEFAULT_MAP_BODY(VectorMapFactory, Type*);
 
+
+  /** The DefaultMapFactory template class is a factory class
+   *  to create maps for the edge and nodes. This map factory
+   *  uses the VectorMapFactory if the ValueType is a primitive
+   *  type and the ArrayMapFactory for the other cases.
+   *
+   *  The template parameter is the MapRegistry that the maps
+   *  will belong to.
+   */
+
   template <typename MapRegistry>
   class DefaultMapFactory {
 		
   public:
-		
+    /// The graph type of the maps. 
     typedef typename MapRegistry::Graph Graph;
-    typedef typename MapRegistry::Key Key;
+    /// The key type of the maps.
+    typedef typename MapRegistry::KeyType KeyType;
+    /// The iterator to iterate on the keys.
     typedef typename MapRegistry::KeyIt KeyIt;
 
+    /// The MapBase of the Map which imlements the core regisitry function.
     typedef typename MapRegistry::MapBase MapBase;
+		
 
+    /** The template Map type.
+     */
     template <typename V> 
     class Map : public DefaultMap<MapRegistry, V> {
 
@@ -115,21 +139,35 @@
       
       typedef V Value;
 
+      /** Default constructor for the map.
+       */
       Map() : MapImpl() {}
 
+      /** Graph and Registry initialized map constructor.
+       */
       Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
 
+      /** Constructor to use default value to initialize the map. 
+       */
       Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {}
 
+      /** Constructor to copy a map of the same map type.
+       */
       Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
 
+      /** Constructor to copy a map of an other map type.
+       */
       template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
 
+      /** Assign operator to copy a map of the same map type.
+       */
       Map& operator=(const Map& copy) {
 	MapImpl::operator=(static_cast<const MapImpl&>(copy));
 	return *this;
       }
 
+      /** Assign operator to copy a map an other map type.
+       */
       template <typename CMap> Map& operator=(const CMap& copy) {
 	MapImpl::operator=(copy);
 	return *this;

Modified: hugo/trunk/src/hugo/vector_map_factory.h
==============================================================================
--- hugo/trunk/src/hugo/vector_map_factory.h	(original)
+++ hugo/trunk/src/hugo/vector_map_factory.h	Fri Sep  3 17:32:03 2004
@@ -128,11 +128,7 @@
        * The subscript operator. The map can be subscripted by the
        * actual keys of the graph. 
        */
-<<<<<<< .mine
-      Reference operator[](const Key& key) {
-=======
-      typename Container::reference operator[](const KeyType& key) {
->>>>>>> .r1091
+      Reference operator[](const KeyType& key) {
 	int id = getGraph()->id(key);
 	return container[id];
       } 
@@ -141,11 +137,7 @@
        * The const subscript operator. The map can be subscripted by the
        * actual keys of the graph. 
        */
-<<<<<<< .mine
-      ConstReference operator[](const Key& key) const {
-=======
-      typename Container::const_reference operator[](const KeyType& key) const {
->>>>>>> .r1091
+      ConstReference operator[](const KeyType& key) const {
 	int id = getGraph()->id(key);
 	return container[id];
       }
@@ -209,7 +201,7 @@
 	  friend class iterator;
 	private:
 	  Reference data;
-	  Pointer(const KeyType& key, Value& val) : data(key, val) {}
+	  Pointer(const KeyType& key, Map::Reference val) : data(key, val) {}
 	public:
 	  Reference* operator->() {return &data;}
 	};
@@ -300,7 +292,8 @@
 	  friend class const_iterator;
 	private:
 	  Reference data;
-	  Pointer(const KeyType& key, const Value& val) : data(key, val) {}
+	  Pointer(const KeyType& key, Map::ConstReference val) 
+	    : data(key, val) {}
 	public:
 	  Reference* operator->() {return &data;}
 	};



More information about the Lemon-commits mailing list