# HG changeset patch # User deba # Date 1094224277 0 # Node ID 6d1abeb62dd338bd96c59fc51bdbd19003d8ccba # Parent a76d8d52b25cbd2a8a53249d9898d1b62f415b1b diff -r a76d8d52b25c -r 6d1abeb62dd3 src/hugo/default_map_factory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugo/default_map_factory.h Fri Sep 03 15:11:17 2004 +0000 @@ -0,0 +1,143 @@ +// -*- c++ -*- +#ifndef DEFAULT_MAP_FACTORY_H +#define DEFAULT_MAP_FACTORY_H + + +#include +#include + +namespace hugo { + +#define DEFAULT_MAP_BODY(Factory, Val) \ + { \ + typedef typename Factory::template Map MapImpl; \ + \ + public: \ + \ + typedef typename MapRegistry::Graph Graph; \ + typedef typename MapRegistry::Key Key; \ + 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*); + + template + class DefaultMapFactory { + + public: + + typedef typename MapRegistry::Graph Graph; + typedef typename MapRegistry::Key Key; + typedef typename MapRegistry::KeyIt KeyIt; + + typedef typename MapRegistry::MapBase MapBase; + + template + class Map : public DefaultMap { + + typedef DefaultMap MapImpl; + + public: + + typedef V Value; + + Map() : MapImpl() {} + + Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} + + Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {} + + Map(const Map& copy) : MapImpl(static_cast(copy)) {} + + template Map(const CMap& copy) : MapImpl(copy) {} + + Map& operator=(const Map& copy) { + MapImpl::operator=(static_cast(copy)); + return *this; + } + + template Map& operator=(const CMap& copy) { + MapImpl::operator=(copy); + return *this; + } + + }; + + }; +} + +#endif diff -r a76d8d52b25c -r 6d1abeb62dd3 src/hugo/full_graph.h --- a/src/hugo/full_graph.h Fri Sep 03 14:26:03 2004 +0000 +++ b/src/hugo/full_graph.h Fri Sep 03 15:11:17 2004 +0000 @@ -13,7 +13,7 @@ #include #include -#include +#include namespace hugo { @@ -48,7 +48,7 @@ class InEdgeIt; CREATE_MAP_REGISTRIES; - CREATE_MAPS(ArrayMapFactory); + CREATE_MAPS(DefaultMapFactory); public: diff -r a76d8d52b25c -r 6d1abeb62dd3 src/hugo/list_graph.h --- a/src/hugo/list_graph.h Fri Sep 03 14:26:03 2004 +0000 +++ b/src/hugo/list_graph.h Fri Sep 03 15:11:17 2004 +0000 @@ -13,7 +13,7 @@ #include #include -#include +#include #include @@ -80,7 +80,7 @@ class InEdgeIt; CREATE_MAP_REGISTRIES; - CREATE_MAPS(ArrayMapFactory); + CREATE_MAPS(DefaultMapFactory); public: @@ -425,7 +425,7 @@ KEEP_EDGE_MAP(ListGraph); CREATE_SYM_EDGE_MAP_REGISTRY; - CREATE_SYM_EDGE_MAP_FACTORY(ArrayMapFactory); + CREATE_SYM_EDGE_MAP_FACTORY(DefaultMapFactory); IMPORT_SYM_EDGE_MAP(SymEdgeMapFactory); SymListGraph() : ListGraph() { } @@ -508,7 +508,7 @@ class InEdgeIt; CREATE_MAP_REGISTRIES; - CREATE_MAPS(ArrayMapFactory); + CREATE_MAPS(DefaultMapFactory); public: @@ -805,7 +805,7 @@ CREATE_EDGE_MAP_REGISTRY; - CREATE_EDGE_MAP_FACTORY(ArrayMapFactory); + CREATE_EDGE_MAP_FACTORY(DefaultMapFactory); IMPORT_EDGE_MAP(EdgeMapFactory); diff -r a76d8d52b25c -r 6d1abeb62dd3 src/hugo/smart_graph.h --- a/src/hugo/smart_graph.h Fri Sep 03 14:26:03 2004 +0000 +++ b/src/hugo/smart_graph.h Fri Sep 03 15:11:17 2004 +0000 @@ -12,7 +12,7 @@ #include -#include +#include #include #include @@ -73,7 +73,7 @@ class InEdgeIt; CREATE_MAP_REGISTRIES; - CREATE_MAPS(ArrayMapFactory); + CREATE_MAPS(DefaultMapFactory); public: @@ -296,7 +296,7 @@ KEEP_EDGE_MAP(SmartGraph); CREATE_SYM_EDGE_MAP_REGISTRY; - CREATE_SYM_EDGE_MAP_FACTORY(ArrayMapFactory); + CREATE_SYM_EDGE_MAP_FACTORY(DefaultMapFactory); IMPORT_SYM_EDGE_MAP(SymEdgeMapFactory); SymSmartGraph() : SmartGraph() { } @@ -305,7 +305,9 @@ Edge addEdge(Node u, Node v) { Edge e = SmartGraph::addEdge(u,v); - SmartGraph::addEdge(v,u); + Edge f = SmartGraph::addEdge(v,u); + sym_edge_maps.add(e); + sym_edge_maps.add(f); return e; } diff -r a76d8d52b25c -r 6d1abeb62dd3 src/hugo/sym_map_factory.h --- a/src/hugo/sym_map_factory.h Fri Sep 03 14:26:03 2004 +0000 +++ b/src/hugo/sym_map_factory.h Fri Sep 03 15:11:17 2004 +0000 @@ -12,7 +12,11 @@ : EdgeIt() {} SymEdgeIt(const Graph& graph) - : EdgeIt(graph) {} + : EdgeIt(graph) { + while ( n != -1 && (n & 1)) { + EdgeIt::operator++(); + } + } SymEdgeIt(Invalid invalid) : EdgeIt(invalid) {} @@ -52,7 +56,8 @@ Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} - Map(const Graph& g, MapRegistry& r, const Value& v) : MapImpl(g, r, v) {} + Map(const Graph& g, MapRegistry& r, const Value& v) + : MapImpl(g, r, v) {} Map(const Map& copy) : MapImpl(static_cast(copy)) {} diff -r a76d8d52b25c -r 6d1abeb62dd3 src/hugo/vector_map_factory.h --- a/src/hugo/vector_map_factory.h Fri Sep 03 14:26:03 2004 +0000 +++ b/src/hugo/vector_map_factory.h Fri Sep 03 15:11:17 2004 +0000 @@ -17,7 +17,7 @@ /** The VectorMapFactory template class is a factory class * to create maps for the edge and nodes. This map factory - * use the std::vector to implement the container function. + * uses the std::vector to implement the container function. * * The template parameter is the MapRegistry that the maps * will belong to. @@ -42,12 +42,27 @@ */ template class Map : public MapBase { + + typedef std::vector Container; + 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 typename Container::reference Reference; + /// The pointer type of the map; + typedef typename Container::pointer Pointer; - typedef std::vector Container; + /// The const value type of the map. + typedef const Value ConstValue; + /// The const reference type of the map; + typedef typename Container::const_reference ConstReference; + /// The pointer type of the map; + typedef typename Container::const_pointer ConstPointer; /** Default constructor for the map. */ @@ -64,7 +79,7 @@ Map(const Graph& g, MapRegistry& r, const Value& v) : MapBase(g, r) { for (KeyIt it(*getGraph()); it != INVALID; ++it) { int id = getGraph()->id(it); - if (id >= container.size()) { + if (id >= (int)container.size()) { container.resize(id + 1); } set(it, v); @@ -77,7 +92,7 @@ if (getGraph()) { for (KeyIt it(*getGraph()); it != INVALID; ++it) { int id = getGraph()->id(it); - if (id >= container.size()) { + if (id >= (int)container.size()) { container.resize(id + 1); } set(it, copy[it]); @@ -95,12 +110,13 @@ if (getGraph()) { for (KeyIt it(*getGraph()); it != INVALID; ++it) { int id = getGraph()->id(it); - if (id >= container.size()) { + if (id >= (int)container.size()) { container.resize(id + 1); } set(it, copy[it]); } } + return *this; } /** The destructor of the map. @@ -112,7 +128,11 @@ * 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 int id = getGraph()->id(key); return container[id]; } @@ -121,7 +141,11 @@ * 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 int id = getGraph()->id(key); return container[id]; } @@ -138,7 +162,7 @@ */ void add(const KeyType& key) { int id = getGraph()->id(key); - if (id >= container.size()) { + if (id >= (int)container.size()) { container.resize(id + 1); } } @@ -173,7 +197,7 @@ iterator() {} typedef extended_pair Reference; + Map::Reference, Map::Reference> Reference; /** Dereference operator for map. */ @@ -263,7 +287,7 @@ const_iterator(iterator p_it) : map(p_it.map), it(p_it.it) {} typedef extended_pair Reference; + Map::ConstReference, Map::ConstReference> Reference; /** Dereference operator for map. */