# HG changeset patch # User deba # Date 1094645205 0 # Node ID 88226d9fe821ddc6c64ce893f37dbacb39581058 # Parent 283a7fe3a00e1ec996ce0aa7a090203fece3d4e6 The MapFactories have been removed from the code because if we use macros then they increases only the complexity. The pair iterators of the maps are separeted from the maps. Some macros and comments has been changed. diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/array_map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugo/array_map.h Wed Sep 08 12:06:45 2004 +0000 @@ -0,0 +1,285 @@ +// -*- c++ -*- +#ifndef ARRAY_MAP_H +#define ARRAY_MAP_H + +#include + +#include + +///\ingroup graphmaps +///\file +///\brief Graph maps that construates and destruates +///their elements dynamically. + +namespace hugo { + + + /// \addtogroup graphmaps + /// @{ + + /** The ArrayMap template class is graph map structure what + * automatically updates the map when a key is added to or erased from + * the map. This map factory uses the allocators to implement + * the container functionality. + * + * The template parameter is the MapRegistry that the maps + * will belong to and the ValueType. + */ + + template + class ArrayMap : public MapRegistry::MapBase { + + 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; + + + public: + + /// The value type of the map. + typedef Value ValueType; + /// The reference type of the map; + typedef Value& ReferenceType; + /// The pointer type of the map; + typedef Value* PointerType; + + /// The const value type of the map. + typedef const Value ConstValueType; + /// The const reference type of the map; + typedef const Value& ConstReferenceType; + /// The pointer type of the map; + typedef const Value* ConstPointerType; + + + typedef std::allocator Allocator; + + + /** Default constructor for the map. + */ + ArrayMap() : values(0), capacity(0) {} + + /** Graph and Registry initialized map constructor. + */ + ArrayMap(const Graph& g, MapRegistry& r) : MapBase(g, r) { + allocate_memory(); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = MapBase::getGraph()->id(it); + allocator.construct(&(values[id]), Value()); + } + } + + /** Constructor to use default value to initialize the map. + */ + ArrayMap(const Graph& g, MapRegistry& r, const Value& v) + : MapBase(g, r) { + allocate_memory(); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = MapBase::getGraph()->id(it); + allocator.construct(&(values[id]), v); + } + } + + /** Constructor to copy a map of the same map type. + */ + ArrayMap(const ArrayMap& copy) : MapBase(*copy.graph, *copy.registry) { + capacity = copy.capacity; + if (capacity == 0) return; + values = allocator.allocate(capacity); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = MapBase::getGraph()->id(it); + allocator.construct(&(values[id]), copy.values[id]); + } + } + + /** Constructor to copy a map of an other map type. + */ + template ArrayMap(const CMap& copy) + : MapBase(copy), capacity(0), values(0) { + if (MapBase::getGraph()) { + allocate_memory(); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + set(it, copy[it]); + } + } + } + + /** Assign operator to copy a map of the same map type. + */ + ArrayMap& operator=(const ArrayMap& copy) { + if (© == this) return *this; + if (capacity != 0) { + MapBase::destroy(); + allocator.deallocate(values, capacity); + } + capacity = copy.capacity; + if (capacity == 0) return *this; + values = allocator.allocate(capacity); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = MapBase::getGraph()->id(it); + allocator.construct(&(values[id]), copy.values[id]); + } + return *this; + } + + /** Assign operator to copy a map an other map type. + */ + template ArrayMap& operator=(const CMap& copy) { + if (MapBase::getGraph()) { + MapBase::destroy(); + } + MapBase::operator=(copy); + if (MapBase::getGraph()) { + allocate_memory(); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + set(it, copy[it]); + } + } + return *this; + } + + /** The destructor of the map. + */ + virtual ~ArrayMap() { + if (capacity != 0) { + MapBase::destroy(); + allocator.deallocate(values, capacity); + } + } + + + /** + * The subscript operator. The map can be subscripted by the + * actual keys of the graph. + */ + ReferenceType 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. + */ + ConstReferenceType operator[](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 ValueType& 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) { + int new_capacity = (capacity == 0 ? 1 : capacity); + while (new_capacity <= id) { + new_capacity <<= 1; + } + Value* new_values = allocator.allocate(new_capacity);; + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int jd = MapBase::getGraph()->id(it); + if (id != jd) { + allocator.construct(&(new_values[jd]), values[jd]); + allocator.destroy(&(values[jd])); + } + } + if (capacity != 0) allocator.deallocate(values, capacity); + values = new_values; + capacity = new_capacity; + } + 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(); + allocator.deallocate(values, capacity); + capacity = 0; + } + } + + /// The stl compatible pair iterator of the map. + typedef MapIterator Iterator; + /// The stl compatible const pair iterator of the map. + typedef MapConstIterator ConstIterator; + + /** Returns the begin iterator of the map. + */ + Iterator begin() { + return Iterator(*this, KeyIt(*MapBase::getGraph())); + } + + /** Returns the end iterator of the map. + */ + Iterator end() { + return Iterator(*this, INVALID); + } + + /** Returns the begin ConstIterator of the map. + */ + ConstIterator begin() const { + return ConstIterator(*this, KeyIt(*MapBase::getGraph())); + } + + /** Returns the end const_iterator of the map. + */ + ConstIterator end() const { + return ConstIterator(*this, INVALID); + } + + private: + + void allocate_memory() { + int max_id = -1; + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = MapBase::getGraph()->id(it); + if (id > max_id) { + max_id = id; + } + } + if (max_id == -1) { + capacity = 0; + values = 0; + return; + } + capacity = 1; + while (capacity <= max_id) { + capacity <<= 1; + } + values = allocator.allocate(capacity); + } + + int capacity; + Value* values; + Allocator allocator; + }; + +/// @} + +} + +#endif diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/array_map_factory.h --- a/src/hugo/array_map_factory.h Wed Sep 08 11:58:06 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,444 +0,0 @@ -// -*- c++ -*- -#ifndef ARRAY_MAP_FACTORY_H -#define ARRAY_MAP_FACTORY_H - -#include - -#include - -///\ingroup graphmapfactory -///\file -///\brief Graph maps that construates and destruates -///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 - 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 > - class Map : public MapBase { - - public: - - /// 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) { - int id = MapBase::getGraph()->id(it); - allocator.construct(&(values[id]), Value()); - } - } - - /** 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) { - int id = MapBase::getGraph()->id(it); - allocator.construct(&(values[id]), v); - } - } - - /** 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; - values = allocator.allocate(capacity); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - int id = MapBase::getGraph()->id(it); - allocator.construct(&(values[id]), copy.values[id]); - } - } - - /** Constructor to copy a map of an other map type. - */ - template Map(const CMap& copy) - : MapBase(copy), capacity(0), values(0) { - if (MapBase::getGraph()) { - allocate_memory(); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - set(it, copy[it]); - } - } - } - - /** Assign operator to copy a map of the same map type. - */ - Map& operator=(const Map& copy) { - if (© == this) return *this; - if (capacity != 0) { - MapBase::destroy(); - allocator.deallocate(values, capacity); - } - capacity = copy.capacity; - if (capacity == 0) return *this; - values = allocator.allocate(capacity); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - int id = MapBase::getGraph()->id(it); - allocator.construct(&(values[id]), copy.values[id]); - } - return *this; - } - - /** Assign operator to copy a map an other map type. - */ - template Map& operator=(const CMap& copy) { - if (MapBase::getGraph()) { - MapBase::destroy(); - } - MapBase::operator=(copy); - if (MapBase::getGraph()) { - allocate_memory(); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - set(it, copy[it]); - } - } - return *this; - } - - /** The destructor of the map. - */ - virtual ~Map() { - if (capacity != 0) { - MapBase::destroy(); - allocator.deallocate(values, capacity); - } - } - - - /** - * 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]; - } - - /** 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) { - int new_capacity = (capacity == 0 ? 1 : capacity); - while (new_capacity <= id) { - new_capacity <<= 1; - } - Value* new_values = allocator.allocate(new_capacity);; - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - int jd = MapBase::getGraph()->id(it); - if (id != jd) { - allocator.construct(&(new_values[jd]), values[jd]); - allocator.destroy(&(values[jd])); - } - } - if (capacity != 0) allocator.deallocate(values, capacity); - values = new_values; - capacity = new_capacity; - } - 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(); - allocator.deallocate(values, capacity); - capacity = 0; - } - } - - class iterator; - class const_iterator; - - /** 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; - private: - - /** Private constructor to initalize the the iterators returned - * by the begin() and end(). - */ - iterator (Map& pmap, const KeyIt& pit) : map(&pmap), it(pit) {} - - public: - - /** Default constructor. - */ - iterator() {} - - typedef extended_pair Reference; - - /** Dereference operator for map. - */ - Reference operator*() { - return Reference(it, (*map)[it]); - } - - class Pointer { - friend class iterator; - private: - Reference data; - Pointer(const KeyType& key, Value& val) : data(key, val) {} - public: - Reference* operator->() {return &data;} - }; - - /** Arrow operator for map. - */ - Pointer operator->() { - return Pointer(it, ((*map)[it])); - } - - /** The pre increment operator of the map. - */ - iterator& operator++() { - ++it; - return *this; - } - - /** The post increment operator of the map. - */ - iterator operator++(int) { - iterator tmp(it); - ++it; - return tmp; - } - - /** The equality operator of the map. - */ - bool operator==(const_iterator p_it) { - return p_it.it == it; - } - - /** The not-equality operator of the map. - */ - bool operator!=(const_iterator p_it) { - return !(*this == p_it); - } - - - private: - Map* map; - KeyIt it; - }; - - /** Returns the begin iterator of the map. - */ - iterator begin() { - return iterator(*this, KeyIt(*MapBase::getGraph())); - } - - /** Returns the end iterator of the map. - */ - iterator end() { - return iterator(*this, INVALID); - } - - class const_iterator { - friend class Map; - friend class iterator; - private: - - /** Private constructor to initalize the the iterators returned - * by the begin() and end(). - */ - const_iterator (const Map& pmap, const KeyIt& pit) - : map(&pmap), it(pit) {} - - public: - - /** Default constructor. - */ - const_iterator() {} - - /** Constructor to convert iterator to const_iterator. - */ - const_iterator(iterator p_it) : map(p_it.map), it(p_it.it) {} - - typedef extended_pair Reference; - - /** Dereference operator for map. - */ - Reference operator*() { - return Reference(it, (*map)[it]); - } - - - class Pointer { - friend class const_iterator; - private: - Reference data; - Pointer(const KeyType& key, const Value& val) : data(key, val) {} - public: - Reference* operator->() {return &data;} - }; - - /** Arrow operator for map. - */ - Pointer operator->() { - return Pointer(it, ((*map)[it])); - } - - /** The pre increment operator of the map. - */ - const_iterator& operator++() { - ++it; - return *this; - } - - /** The post increment operator of the map. - */ - const_iterator operator++(int) { - const_iterator tmp(it); - ++it; - return tmp; - } - - /** The equality operator of the map. - */ - bool operator==(const_iterator p_it) { - return p_it.it == it; - } - - /** The not-equality operator of the map. - */ - bool operator!=(const_iterator p_it) { - return !(*this == p_it); - } - - - private: - const Map* map; - KeyIt it; - }; - - /** Returns the begin const_iterator of the map. - */ - const_iterator begin() const { - return const_iterator(*this, KeyIt(*MapBase::getGraph())); - } - - /** Returns the end const_iterator of the map. - */ - const_iterator end() const { - return const_iterator(*this, INVALID); - } - - private: - - void allocate_memory() { - int max_id = -1; - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - int id = MapBase::getGraph()->id(it); - if (id > max_id) { - max_id = id; - } - } - if (max_id == -1) { - capacity = 0; - values = 0; - return; - } - capacity = 1; - while (capacity <= max_id) { - capacity <<= 1; - } - values = allocator.allocate(capacity); - } - - int capacity; - Value* values; - Allocator allocator; - }; - }; - -/// @} - -} - -#endif diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/default_map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugo/default_map.h Wed Sep 08 12:06:45 2004 +0000 @@ -0,0 +1,115 @@ +// -*- c++ -*- +#ifndef DEFAULT_MAP_H +#define DEFAULT_MAP_H + + +#include +#include + +///\ingroup graphmaps +///\file +///\brief Graph maps that construates and destruates +///their elements dynamically. + +namespace hugo { + +/// \addtogroup graphmaps +/// @{ + + /** The ArrayMap template class is graph map structure what + * automatically updates the map when a key is added to or erased from + * the map. This map uses the VectorMap if the ValueType is a primitive + * type and the ArrayMap for the other cases. + * + * The template parameter is the MapRegistry that the maps + * will belong to and the ValueType. + */ + + + /** Macro to implement the DefaultMap. + */ +#define DEFAULT_MAP_BODY(DynMap, Value) \ + { \ + typedef DynMap MapImpl; \ + \ + public: \ + \ + typedef typename MapRegistry::Graph Graph; \ + \ + DefaultMap() : MapImpl() {} \ + \ + DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \ + \ + DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \ + : MapImpl(g, r, v) {} \ + \ + DefaultMap(const DefaultMap& copy) \ + : MapImpl(static_cast(copy)) {} \ + \ + template DefaultMap(const CMap& copy) : MapImpl(copy) {} \ + \ + DefaultMap& operator=(const DefaultMap& copy) { \ + MapImpl::operator=(static_cast(copy)); \ + return *this; \ + } \ + \ + template DefaultMap& operator=(const CMap& copy) { \ + MapImpl::operator=(copy); \ + return *this; \ + } \ + \ + }; + + + template + class DefaultMap : public ArrayMap + DEFAULT_MAP_BODY(ArrayMap, Type); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, bool); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, char); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, int); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, short); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, long); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, float); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, double); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, long double); + + template + class DefaultMap + : public VectorMap + DEFAULT_MAP_BODY(VectorMap, Type*); + +} + +#endif diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/default_map_factory.h --- a/src/hugo/default_map_factory.h Wed Sep 08 11:58:06 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,181 +0,0 @@ -// -*- c++ -*- -#ifndef DEFAULT_MAP_FACTORY_H -#define DEFAULT_MAP_FACTORY_H - - -#include -#include - -///\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::template Map MapImpl; \ - \ - public: \ - \ - typedef typename MapRegistry::Graph Graph; \ - typedef typename MapRegistry::KeyType KeyType; \ - typedef typename MapRegistry::KeyIt KeyIt; \ - typedef Val Value; \ - \ - typedef typename MapRegistry::MapBase MapBase; \ - \ - DefaultMap() : MapImpl() {} \ - \ - DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \ - \ - DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \ - : MapImpl(g, r, v) {} \ - \ - DefaultMap(const DefaultMap& copy) \ - : MapImpl(static_cast(copy)) {} \ - \ - template DefaultMap(const CMap& copy) : MapImpl(copy) {} \ - \ - DefaultMap& operator=(const DefaultMap& copy) { \ - MapImpl::operator=(static_cast(copy)); \ - return *this; \ - } \ - \ - template DefaultMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy); \ - return *this; \ - } \ - \ - }; - - - template - class DefaultMap : public ArrayMapFactory::template Map - DEFAULT_MAP_BODY(ArrayMapFactory, Type); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, bool); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, char); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, int); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, short); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, long); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, float); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, double); - - template - class DefaultMap - : public VectorMapFactory::template Map - DEFAULT_MAP_BODY(VectorMapFactory, long double); - - template - class DefaultMap - : public VectorMapFactory::template Map - 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 - class DefaultMapFactory { - - 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 - class Map : public DefaultMap { - - typedef DefaultMap MapImpl; - - public: - - 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(copy)) {} - - /** Constructor to copy a map of an other map type. - */ - template 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(copy)); - return *this; - } - - /** Assign operator to copy a map an other map type. - */ - template Map& operator=(const CMap& copy) { - MapImpl::operator=(copy); - return *this; - } - - }; - - }; -} - -#endif diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/full_graph.h --- a/src/hugo/full_graph.h Wed Sep 08 11:58:06 2004 +0000 +++ b/src/hugo/full_graph.h Wed Sep 08 12:06:45 2004 +0000 @@ -13,7 +13,9 @@ #include #include -#include +#include + +#include namespace hugo { @@ -47,8 +49,11 @@ class OutEdgeIt; class InEdgeIt; + + /// Creating map registries. CREATE_MAP_REGISTRIES; - CREATE_MAPS(DefaultMapFactory); + /// Creating node and edge maps. + CREATE_MAPS(DefaultMap); public: diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/list_graph.h --- a/src/hugo/list_graph.h Wed Sep 08 11:58:06 2004 +0000 +++ b/src/hugo/list_graph.h Wed Sep 08 12:06:45 2004 +0000 @@ -13,9 +13,9 @@ #include #include -#include +#include -#include +#include #include @@ -79,8 +79,10 @@ class OutEdgeIt; class InEdgeIt; + /// Creating map registries. CREATE_MAP_REGISTRIES; - CREATE_MAPS(DefaultMapFactory); + /// Creating node and edge maps. + CREATE_MAPS(DefaultMap); public: @@ -443,12 +445,13 @@ typedef SymListGraph Graph; - KEEP_NODE_MAP(ListGraph); - KEEP_EDGE_MAP(ListGraph); + /// Importing maps from the base class ListGraph. + KEEP_MAPS(ListGraph, SymListGraph); + /// Creating symmetric map registry. CREATE_SYM_EDGE_MAP_REGISTRY; - CREATE_SYM_EDGE_MAP_FACTORY(DefaultMapFactory); - IMPORT_SYM_EDGE_MAP(SymEdgeMapFactory); + /// Creating symmetric edge map. + CREATE_SYM_EDGE_MAP(DefaultMap); SymListGraph() : ListGraph() { } SymListGraph(const ListGraph &_g) : ListGraph(_g) { } @@ -529,8 +532,40 @@ class OutEdgeIt; class InEdgeIt; - CREATE_MAP_REGISTRIES; - CREATE_MAPS(DefaultMapFactory); + /// Creating node map registry. + CREATE_NODE_MAP_REGISTRY; + /// Creating node maps. + CREATE_NODE_MAP(DefaultMap); + + /// Creating empty map structure for edges. + template + class EdgeMap { + public: + EdgeMap() {} + EdgeMap(const Graph&) {} + EdgeMap(const Graph&, const Value&) {} + + EdgeMap(const EdgeMap&) {} + template EdgeMap(const CMap&) {} + + EdgeMap& operator=(const EdgeMap&) {} + template EdgeMap& operator=(const CMap&) {} + + class ConstIterator { + public: + bool operator==(const ConstIterator&) {return true;} + bool operator!=(const ConstIterator&) {return false;} + }; + + typedef ConstIterator Iterator; + + Iterator begin() { return Iterator();} + Iterator end() { return Iterator();} + + ConstIterator begin() const { return ConstIterator();} + ConstIterator end() const { return ConstIterator();} + + }; public: @@ -848,9 +883,13 @@ class InEdgeIt; + /// Creating edge map registry. CREATE_EDGE_MAP_REGISTRY; - CREATE_EDGE_MAP_FACTORY(DefaultMapFactory); - IMPORT_EDGE_MAP(EdgeMapFactory); + /// Creating edge maps. + CREATE_EDGE_MAP(DefaultMap); + + /// Importing node maps from the NodeGraphType. + IMPORT_NODE_MAP(NodeGraphType, graph.G, EdgeSet, graph); public: @@ -1090,42 +1129,7 @@ : Edge(_G.nodes[v].first_in), G(&_G) { } InEdgeIt &operator++() { n=G->edges[n].next_in; return *this; } }; - - template class NodeMap - : public NodeGraphType::template NodeMap - { - //This is a must, the constructors need it. - typedef typename NodeGraphType::template NodeMap MapImpl; - typedef V Value; - public: - NodeMap() : MapImpl() {} - - NodeMap(const EdgeSet& graph) - : MapImpl(graph.G) { } - - NodeMap(const EdgeSet& graph, const Value& value) - : MapImpl(graph.G, value) { } - - NodeMap(const NodeMap& copy) - : MapImpl(static_cast(copy)) {} - - template - NodeMap(const CMap& copy) - : MapImpl(copy) { } - - NodeMap& operator=(const NodeMap& copy) { - MapImpl::operator=(static_cast(copy)); - return *this; - } - - template - NodeMap& operator=(const CMap& copy) { - MapImpl::operator=(copy); - return *this; - } - - }; }; template diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/map_defines.h --- a/src/hugo/map_defines.h Wed Sep 08 11:58:06 2004 +0000 +++ b/src/hugo/map_defines.h Wed Sep 08 12:06:45 2004 +0000 @@ -2,7 +2,7 @@ #ifndef MAP_DEFINES_H #define MAP_DEFINES_H -///\ingroup graphmapfactory +///\ingroup graphmaps ///\file ///\brief Defines to help creating graph maps. @@ -29,38 +29,22 @@ CREATE_NODE_MAP_REGISTRY \ CREATE_EDGE_MAP_REGISTRY -/** Creates a concrete factory type from a template map - * factory to use as node map factory. - */ -#define CREATE_NODE_MAP_FACTORY(TemplateFactory) \ -typedef TemplateFactory NodeMapFactory; - -/** Creates a concrete factory type from a template map - * factory to use as edge map factory. - */ -#define CREATE_EDGE_MAP_FACTORY(TemplateFactory) \ -typedef TemplateFactory EdgeMapFactory; - -/** Creates both map factories. - */ -#define CREATE_MAP_FACTORIES(TemplateFactory) \ -CREATE_NODE_MAP_FACTORY(TemplateFactory) \ -CREATE_EDGE_MAP_FACTORY(TemplateFactory) - -/** Import a map from a concrete map factory. The import method is +/** Creates a map from a template map. The import method is * an overloading of the map type. * The reason to use these macro is that the c++ does not support * the template typedefs. If a future release of the c++ * supports this feature it should be fixed. */ -#define IMPORT_NODE_MAP(Factory) \ -template \ -class NodeMap : public Factory::template Map { \ -typedef typename Factory::template Map MapImpl; \ +#define CREATE_NODE_MAP(DynMap) \ +template \ +class NodeMap : public DynMap { \ +typedef DynMap MapImpl; \ public: \ NodeMap() {} \ -NodeMap(const Graph& g) : MapImpl(g, g.node_maps) {} \ -NodeMap(const Graph& g, const V& v) : MapImpl(g, g.node_maps, v) {} \ +NodeMap(const typename MapImpl::Graph& g) \ + : MapImpl(g, g.node_maps) {} \ +NodeMap(const typename MapImpl::Graph& g, const Value& v) \ + : MapImpl(g, g.node_maps, v) {} \ NodeMap(const NodeMap& copy) : MapImpl(static_cast(copy)) {} \ template NodeMap(const CMap& copy) : MapImpl(copy) {} \ NodeMap& operator=(const NodeMap& copy) { \ @@ -73,20 +57,22 @@ } \ }; -/** Import a map from a concrete map factory. The import method is +/** Creates a map from a template map. The import method is * an overloading of the map type. * The reason to use these macro is that the c++ does not support * the template typedefs. If a future release of the c++ * supports this feature it should be fixed. */ -#define IMPORT_EDGE_MAP(Factory) \ -template \ -class EdgeMap : public Factory::template Map { \ -typedef typename Factory::template Map MapImpl; \ +#define CREATE_EDGE_MAP(DynMap) \ +template \ +class EdgeMap : public DynMap { \ +typedef DynMap MapImpl; \ public: \ EdgeMap() {} \ -EdgeMap(const Graph& g) : MapImpl(g, g.edge_maps) {} \ -EdgeMap(const Graph& g, const V& v) : MapImpl(g, g.edge_maps, v) {} \ +EdgeMap(const typename MapImpl::Graph& g) \ + : MapImpl(g, g.edge_maps) {} \ +EdgeMap(const typename MapImpl::Graph& g, const Value& v) \ + : MapImpl(g, g.edge_maps, v) {} \ EdgeMap(const EdgeMap& copy) : MapImpl(static_cast(copy)) {} \ template EdgeMap(const CMap& copy) : MapImpl(copy) {} \ EdgeMap& operator=(const EdgeMap& copy) { \ @@ -99,12 +85,11 @@ } \ }; -/** This macro creates both map factories and imports both maps. +/** This macro creates both maps. */ -#define CREATE_MAPS(TemplateFactory) \ -CREATE_MAP_FACTORIES(TemplateFactory) \ -IMPORT_NODE_MAP(NodeMapFactory) \ -IMPORT_EDGE_MAP(EdgeMapFactory) +#define CREATE_MAPS(DynMap) \ +CREATE_NODE_MAP(DynMap) \ +CREATE_EDGE_MAP(DynMap) /** This macro creates MapRegistry for Symmetric Edge Maps. */ @@ -113,109 +98,119 @@ typedef MapRegistry SymEdgeMapRegistry; \ mutable EdgeMapRegistry sym_edge_maps; -/** Creates a concrete factory type from a template map - * factory to use as edge map factory. - */ -#define CREATE_SYM_EDGE_MAP_FACTORY(TemplateFactory) \ -typedef SymMapFactory \ -SymEdgeMapFactory; -/** Import a map from a concrete map factory. The import method is +/** Creates a map from a template map. The import method is * an overloading of the map type. * The reason to use these macro is that the c++ does not support * the template typedefs. If a future release of the c++ * supports this feature it should be fixed. */ -#define IMPORT_SYM_EDGE_MAP(Factory) \ -template \ -class SymEdgeMap : public Factory::template Map { \ -typedef typename Factory::template Map MapImpl; \ -public: \ -SymEdgeMap() {} \ -SymEdgeMap(const Graph& g) : MapImpl(g, g.sym_edge_maps) {} \ -SymEdgeMap(const Graph& g, const V& v) : MapImpl(g, g.sym_edge_maps, v) {} \ -SymEdgeMap(const SymEdgeMap& copy) \ - : MapImpl(static_cast(copy)) {} \ -template SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \ -SymEdgeMap& operator=(const SymEdgeMap& copy) { \ - MapImpl::operator=(static_cast(copy));\ - return *this; \ -} \ -template SymEdgeMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy);\ - return *this; \ -} \ +#define CREATE_SYM_EDGE_MAP(DynMap) \ +template \ +class SymEdgeMap : public SymMap { \ + typedef SymMap MapImpl; \ + public: \ +\ + SymEdgeMap() {} \ +\ + SymEdgeMap(const typename MapImpl::Graph& g) \ + : MapImpl(g, g.sym_edge_maps) {} \ +\ + SymEdgeMap(const typename MapImpl::Graph& g, const Value& v) \ + : MapImpl(g, g.sym_edge_maps, v) {} \ +\ + SymEdgeMap(const SymEdgeMap& copy) \ + : MapImpl(static_cast(copy)) {} \ +\ + template SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \ + SymEdgeMap& operator=(const SymEdgeMap& copy) { \ + MapImpl::operator=(static_cast(copy));\ + return *this; \ + } \ +\ + template SymEdgeMap& operator=(const CMap& copy) { \ + MapImpl::operator=(copy);\ + return *this; \ + } \ }; -#define KEEP_NODE_MAP(GraphBase) \ - template class NodeMap \ - : public GraphBase::template NodeMap \ - { \ - typedef typename GraphBase::template NodeMap MapImpl; \ - typedef V Value; \ - public: \ - NodeMap() : MapImpl() {} \ +/** This is a macro to import an node map into a graph class. + */ +#define IMPORT_NODE_MAP(From, from, To, to) \ +template \ +class NodeMap \ + : public From::template NodeMap { \ + typedef typename From::template NodeMap MapImpl; \ + public: \ + NodeMap() : MapImpl() {} \ \ - NodeMap(const Graph& graph) \ - : MapImpl(static_cast(graph)) { } \ + NodeMap(const To& to) \ + : MapImpl(static_cast(from)) { } \ \ - NodeMap(const Graph& graph, const Value& value) \ - : MapImpl(static_cast(graph), value) { } \ + NodeMap(const To& to, const Value& value) \ + : MapImpl(static_cast(from), value) { } \ \ - NodeMap(const NodeMap& copy) \ - : MapImpl(static_cast(copy)) {} \ + NodeMap(const NodeMap& copy) \ + : MapImpl(static_cast(copy)) {} \ \ - template \ - NodeMap(const CMap& copy) \ - : MapImpl(copy) {} \ + template \ + NodeMap(const CMap& copy) \ + : MapImpl(copy) {} \ \ - NodeMap& operator=(const NodeMap& copy) { \ - MapImpl::operator=(static_cast(copy)); \ - return *this; \ - } \ + NodeMap& operator=(const NodeMap& copy) { \ + MapImpl::operator=(static_cast(copy)); \ + return *this; \ + } \ \ - template \ - NodeMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy); \ - return *this; \ - } \ - }; + template \ + NodeMap& operator=(const CMap& copy) { \ + MapImpl::operator=(copy); \ + return *this; \ + } \ +}; -#define KEEP_EDGE_MAP(GraphBase) \ - template class EdgeMap \ - : public GraphBase::template EdgeMap \ - { \ - typedef typename GraphBase::template EdgeMap MapImpl; \ - typedef V Value; \ - public: \ - EdgeMap() : MapImpl() {} \ +/** This is a macro to import an edge map into a graph class. + */ +#define IMPORT_EDGE_MAP(From, from, To, to) \ +template \ +class EdgeMap \ + : public From::template EdgeMap { \ + typedef typename From::template EdgeMap MapImpl; \ + public: \ + EdgeMap() : MapImpl() {} \ \ - EdgeMap(const Graph& graph) \ - : MapImpl(static_cast(graph)) { } \ + EdgeMap(const To& to) \ + : MapImpl(static_cast(from)) { } \ \ - EdgeMap(const Graph& graph, const Value& value) \ - : MapImpl(static_cast(graph), value) { } \ + EdgeMap(const To& to, const Value& value) \ + : MapImpl(static_cast(from), value) { } \ \ - EdgeMap(const EdgeMap& copy) \ - : MapImpl(static_cast(copy)) {} \ + EdgeMap(const EdgeMap& copy) \ + : MapImpl(static_cast(copy)) {} \ \ - template \ - EdgeMap(const CMap& copy) \ - : MapImpl(copy) {} \ + template \ + EdgeMap(const CMap& copy) \ + : MapImpl(copy) {} \ \ - EdgeMap& operator=(const EdgeMap& copy) { \ - MapImpl::operator=(static_cast(copy)); \ - return *this; \ - } \ + EdgeMap& operator=(const EdgeMap& copy) { \ + MapImpl::operator=(static_cast(copy)); \ + return *this; \ + } \ \ - template \ - EdgeMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy); \ - return *this; \ - } \ - }; + template \ + EdgeMap& operator=(const CMap& copy) { \ + MapImpl::operator=(copy); \ + return *this; \ + } \ +}; + +/** This is a macro to keep the node and edge maps for a graph class. + */ +#define KEEP_MAPS(From, To) \ +IMPORT_EDGE_MAP(From, graph, To, graph) \ +IMPORT_NODE_MAP(From, graph, To, graph) /// @} diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/map_iterator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugo/map_iterator.h Wed Sep 08 12:06:45 2004 +0000 @@ -0,0 +1,243 @@ +// -*- c++ -*- +#ifndef MAP_ITERATOR_H +#define MAP_ITERATOR_H + +#include + +namespace hugo { + + + template + class MapIterator; + + template + class MapConstIterator; + + /** Compatible iterator with the stl maps' iterators. + * It iterates on pairs of a key and a value. + */ + template + class MapIterator { + // friend class Map; + friend class MapConstIterator; + + public: + + /// The key type of the iterator. + typedef typename Map::KeyType KeyType; + /// The iterator to iterate on the keys. + typedef typename Map::KeyIt KeyIt; + + /// The value type of the iterator. + typedef typename Map::ValueType ValueType; + /// The reference type of the iterator. + typedef typename Map::ReferenceType ReferenceType; + /// The pointer type of the iterator. + typedef typename Map::PointerType PointerType; + + /// The const value type of the iterator. + typedef typename Map::ConstValueType ConstValueType; + /// The const reference type of the iterator. + typedef typename Map::ConstReferenceType ConstReferenceType; + /// The pointer type of the iterator. + typedef typename Map::ConstPointerType ConstPointerType; + + public: + + /** Constructor to initalize the the iterators returned + * by the begin() and end(). + */ + MapIterator (Map& pmap, const KeyIt& pit) + : map(&pmap), it(pit) {} + + public: + + /** Default constructor. + */ + MapIterator() {} + + typedef extended_pair PairReferenceType; + + /** Dereference operator for map. + */ + PairReferenceType operator*() { + return PairReferenceType(it, (*map)[it]); + } + + class PairPointerType { + friend class MapIterator; + private: + PairReferenceType data; + PairPointerType(const KeyType& key, ReferenceType val) + : data(key, val) {} + public: + PairReferenceType* operator->() {return &data;} + }; + + /** Arrow operator for map. + */ + PairPointerType operator->() { + return PairPointerType(it, ((*map)[it])); + } + + /** The pre increment operator of the map. + */ + MapIterator& operator++() { + ++it; + return *this; + } + + /** The post increment operator of the map. + */ + MapIterator operator++(int) { + MapIterator tmp(it); + ++it; + return tmp; + } + + /** The equality operator of the map. + */ + bool operator==(const MapIterator& p_it) const { + return p_it.it == it; + } + + /** The not-equality operator of the map. + */ + bool operator!=(const MapIterator& p_it) const { + return !(*this == p_it); + } + + /** The equality operator of the map. + */ + bool operator==(const MapConstIterator& p_it) const { + return p_it.it == it; + } + + /** The not-equality operator of the map. + */ + bool operator!=(const MapConstIterator& p_it) const { + return !(*this == p_it); + } + + private: + Map* map; + KeyIt it; + }; + + /** Compatible iterator with the stl maps' iterators. + * It iterates on pairs of a key and a value. + */ + template + class MapConstIterator { + // friend class Map; + friend class MapIterator; + + public: + + /// The key type of the iterator. + typedef typename Map::KeyType KeyType; + /// The iterator to iterate on the keys. + typedef typename Map::KeyIt KeyIt; + + /// The value type of the iterator. + typedef typename Map::ValueType ValueType; + /// The reference type of the iterator. + typedef typename Map::ReferenceType ReferenceType; + /// The pointer type of the iterator. + typedef typename Map::PointerType PointerType; + + /// The const value type of the iterator. + typedef typename Map::ConstValueType ConstValueType; + /// The const reference type of the iterator. + typedef typename Map::ConstReferenceType ConstReferenceType; + /// The pointer type of the iterator. + typedef typename Map::ConstPointerType ConstPointerType; + + public: + + /** Constructor to initalize the the iterators returned + * by the begin() and end(). + */ + + MapConstIterator (const Map& pmap, const KeyIt& pit) + : map(&pmap), it(pit) {} + + public: + + /** Default constructor. + */ + MapConstIterator() {} + + typedef extended_pair PairReferenceType; + + /** Dereference operator for map. + */ + PairReferenceType operator*() { + return PairReferenceType(it, (*map)[it]); + } + + class PairPointerType { + friend class MapConstIterator; + private: + PairReferenceType data; + PairPointerType(const KeyType& key, ConstReferenceType val) + : data(key, val) {} + public: + PairReferenceType* operator->() {return &data;} + }; + + /** Arrow operator for map. + */ + PairPointerType operator->() { + return PairPointerType(it, ((*map)[it])); + } + + /** The pre increment operator of the map. + */ + MapConstIterator& operator++() { + ++it; + return *this; + } + + /** The post increment operator of the map. + */ + MapConstIterator operator++(int) { + MapConstIterator tmp(it); + ++it; + return tmp; + } + + /** The equality operator of the map. + */ + bool operator==(const MapIterator& p_it) const { + return p_it.it == it; + } + + /** The not-equality operator of the map. + */ + bool operator!=(const MapIterator& p_it) const { + return !(*this == p_it); + } + + /** The equality operator of the map. + */ + bool operator==(const MapConstIterator& p_it) const { + return p_it.it == it; + } + + /** The not-equality operator of the map. + */ + bool operator!=(const MapConstIterator& p_it) const { + return !(*this == p_it); + } + + private: + const Map* map; + KeyIt it; + }; + +} + +#endif diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/map_registry.h --- a/src/hugo/map_registry.h Wed Sep 08 11:58:06 2004 +0000 +++ b/src/hugo/map_registry.h Wed Sep 08 12:06:45 2004 +0000 @@ -28,8 +28,6 @@ typedef K KeyType; typedef KIt KeyIt; - - /** * MapBase is the base class of the registered maps. * It defines the core modification operations on the maps and diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/smart_graph.h --- a/src/hugo/smart_graph.h Wed Sep 08 11:58:06 2004 +0000 +++ b/src/hugo/smart_graph.h Wed Sep 08 12:06:45 2004 +0000 @@ -12,8 +12,9 @@ #include -#include -#include +#include +#include + #include #include @@ -72,8 +73,10 @@ class OutEdgeIt; class InEdgeIt; + /// Creating map registries. CREATE_MAP_REGISTRIES; - CREATE_MAPS(DefaultMapFactory); + /// Creating node and edge maps. + CREATE_MAPS(DefaultMap); public: @@ -314,12 +317,14 @@ public: typedef SymSmartGraph Graph; - KEEP_NODE_MAP(SmartGraph); - KEEP_EDGE_MAP(SmartGraph); + /// Importing maps from the base class ListGraph. + KEEP_MAPS(SmartGraph, SymSmartGraph); + /// Creating symmetric map registry. CREATE_SYM_EDGE_MAP_REGISTRY; - CREATE_SYM_EDGE_MAP_FACTORY(DefaultMapFactory); - IMPORT_SYM_EDGE_MAP(SymEdgeMapFactory); + /// Creating symmetric edge map. + CREATE_SYM_EDGE_MAP(DefaultMap); + SymSmartGraph() : SmartGraph() { } SymSmartGraph(const SmartGraph &_g) : SmartGraph(_g) { } diff -r 283a7fe3a00e -r 88226d9fe821 src/hugo/sym_map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugo/sym_map.h Wed Sep 08 12:06:45 2004 +0000 @@ -0,0 +1,170 @@ +// -*- c++ -*- +#ifndef SYM_MAP_H +#define SYM_MAP_H + +///\ingroup graphmaps +///\file +///\brief Graph maps that construates and destruates +///their elements dynamically. + +namespace hugo { + +/// \addtogroup graphmaps +/// @{ + + /** The SymEdgeIt is wrapper class for the EdgeIt. It can be used to + * iterate on the symmetric maps when all of the edge - reverse edge pair + * has different parity. + */ + + template + class SymEdgeIt : public EdgeIt { + public: + + /** Default constructor. + */ + SymEdgeIt() + : EdgeIt() {} + + /** Graph initialized constructor. + */ + SymEdgeIt(const Graph& graph) + : EdgeIt(graph) { + while ( (n & 1) && n != -1) { + EdgeIt::operator++(); + } + } + + /** Creating invelid SymEdgeIt. + */ + SymEdgeIt(Invalid invalid) + : EdgeIt(invalid) {} + + /** SymEdgeIt from the given Edge. + */ + SymEdgeIt(const Graph& graph, const Edge& edge) + : EdgeIt(graph, edge) { + while ( (n & 1) && n != -1) { + EdgeIt::operator++(); + } + } + + /** Increase operator. + */ + SymEdgeIt& operator++() { + EdgeIt::operator++(); + while ( (n & 1) && n != -1) { + EdgeIt::operator++(); + } + return *this; + } + }; + + /** The SymMap template class is graph map structure what + * wraps an other map structure to use as symmetric map structure. + * + * The template parameter is the MapRegistry that the maps + * will belong to and the ValueType. + */ + template