# HG changeset patch # User deba # Date 1095721068 0 # Node ID 74589d20dbc315d543a8e02f9ffc45d7d85a4edd # Parent 3a48bc350e0f0c7d71111c417f6fa25c40563cbd template Map(const CMap&) like constructors and assigns are removed. diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/array_map.h --- a/src/hugo/array_map.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/array_map.h Mon Sep 20 22:57:48 2004 +0000 @@ -65,7 +65,7 @@ /** Default constructor for the map. */ - ArrayMap() : values(0), capacity(0) {} + ArrayMap() : capacity(0), values(0) {} /** Graph and Registry initialized map constructor. */ @@ -90,7 +90,7 @@ /** Constructor to copy a map of the same map type. */ - ArrayMap(const ArrayMap& copy) : MapBase(*copy.graph, *copy.registry) { + ArrayMap(const ArrayMap& copy) : MapBase(copy) { capacity = copy.capacity; if (capacity == 0) return; values = allocator.allocate(capacity); @@ -102,13 +102,15 @@ /** 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]); - } + template + ArrayMap(const ArrayMap& copy) + : MapBase(copy) { + capacity = copy.capacity; + if (capacity == 0) return; + values = allocator.allocate(capacity); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = KeyInfo::id(*MapBase::getGraph(), it); + allocator.construct(&(values[id]), copy.values[id]); } } @@ -116,34 +118,46 @@ */ ArrayMap& operator=(const ArrayMap& copy) { if (© == this) return *this; + if (capacity != 0) { MapBase::destroy(); allocator.deallocate(values, 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::id(*MapBase::getGraph(), it); allocator.construct(&(values[id]), copy.values[id]); } + return *this; } - /** Assign operator to copy a map an other map type. + /** Assign operator to copy a map of an other map type. */ - template ArrayMap& operator=(const CMap& copy) { + template + ArrayMap& operator=(const ArrayMap& copy) { if (capacity != 0) { MapBase::destroy(); allocator.deallocate(values, capacity); } + MapBase::operator=(copy); - if (MapBase::getGraph()) { - allocate_memory(); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - set(it, copy[it]); - } + + capacity = copy.capacity; + if (capacity == 0) return *this; + values = allocator.allocate(capacity); + + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = KeyInfo::id(*MapBase::getGraph(), it); + allocator.construct(&(values[id]), copy.values[id]); } + return *this; } diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/default_map.h --- a/src/hugo/default_map.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/default_map.h Mon Sep 20 22:57:48 2004 +0000 @@ -29,36 +29,48 @@ /** 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; \ +{ \ +\ +public: \ +\ +typedef DynMap Parent; \ +\ +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(copy)) {} \ +template \ +DefaultMap(const DefaultMap& copy) { \ + Parent::MapBase::operator= \ + (static_cast(copy)); \ + if (Parent::getGraph()) { \ + for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\ + Parent::add(it); \ + Parent::operator[](it) = copy[it]; \ } \ - \ - template DefaultMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy); \ - return *this; \ + } \ +} \ +DefaultMap& operator=(const DefaultMap& copy) { \ + Parent::operator=(static_cast(copy)); \ + return *this; \ +} \ +template \ +DefaultMap& operator=(const DefaultMap& copy) { \ + Parent::clear(); \ + Parent::MapBase::operator=(copy); \ + if (Parent::getGraph()) { \ + for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\ + Parent::add(it); \ + Parent::operator[](it) = copy[it]; \ } \ - \ - }; + } \ + return *this; \ +} \ +}; template diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/graph_wrapper.h --- a/src/hugo/graph_wrapper.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/graph_wrapper.h Mon Sep 20 22:57:48 2004 +0000 @@ -286,7 +286,7 @@ Node head(const Edge& e) const { return GraphWrapper::tail(e); } - KEEP_MAPS(Parent, RevGraphWrapper); + // KEEP_MAPS(Parent, RevGraphWrapper); }; @@ -493,7 +493,7 @@ return i; } - KEEP_MAPS(Parent, SubGraphWrapper); + // KEEP_MAPS(Parent, SubGraphWrapper); }; @@ -558,14 +558,14 @@ if (e.out_or_in) return this->graph->head(e); else return this->graph->tail(e); } - KEEP_MAPS(Parent, UndirGraphWrapper); + // KEEP_MAPS(Parent, UndirGraphWrapper); }; /// \brief An undirected graph template. /// ///\warning Graph wrappers are in even more experimental state than the other - ///parts of the lib. Use them at you own risk. + ///parts of the lib. Use them at your own risk. /// /// An undirected graph template. /// This class works as an undirected graph and a directed graph of @@ -581,7 +581,7 @@ Parent::setGraph(gr); } - KEEP_MAPS(Parent, UndirGraph); + // KEEP_MAPS(Parent, UndirGraph); }; @@ -894,28 +894,54 @@ /// Graph::EdgeMap one for the forward edges and /// one for the backward edges. class EdgeMap { + template friend class EdgeMap; typename Graph::template EdgeMap forward_map, backward_map; public: typedef T ValueType; typedef Edge KeyType; + EdgeMap(const SubBidirGraphWrapper& g) : forward_map(*(g.graph)), backward_map(*(g.graph)) { } + EdgeMap(const SubBidirGraphWrapper& g, T a) : forward_map(*(g.graph), a), backward_map(*(g.graph), a) { } + + template + EdgeMap(const EdgeMap& copy) + : forward_map(copy.forward_map), backward_map(copy.backward_map) {} + + template + EdgeMap& operator=(const EdgeMap& copy) { + forward_map = copy.forward_map; + backward_map = copy.backward_map; + return *this; + } + void set(Edge e, T a) { if (!e.backward) forward_map.set(e, a); else backward_map.set(e, a); } - T operator[](Edge e) const { + + typename Graph::template EdgeMap::ConstReferenceType + operator[](Edge e) const { if (!e.backward) return forward_map[e]; else return backward_map[e]; } + + typename Graph::template EdgeMap::ReferenceType + operator[](Edge e) { + if (!e.backward) + return forward_map[e]; + else + return backward_map[e]; + } + void update() { forward_map.update(); backward_map.update(); @@ -923,7 +949,7 @@ }; - KEEP_NODE_MAP(Parent, SubBidirGraphWrapper); + // KEEP_NODE_MAP(Parent, SubBidirGraphWrapper); }; @@ -965,7 +991,7 @@ int edgeNum() const { return 2*this->graph->edgeNum(); } - KEEP_MAPS(Parent, BidirGraphWrapper); + // KEEP_MAPS(Parent, BidirGraphWrapper); }; @@ -991,7 +1017,7 @@ BidirGraph() : BidirGraphWrapper() { Parent::setGraph(gr); } - KEEP_MAPS(Parent, BidirGraph); + // KEEP_MAPS(Parent, BidirGraph); }; @@ -1106,7 +1132,7 @@ } }; - KEEP_MAPS(Parent, ResGraphWrapper); + // KEEP_MAPS(Parent, ResGraphWrapper); }; @@ -1168,7 +1194,7 @@ first_out_edges->set(n, f); } - KEEP_MAPS(Parent, ErasingFirstGraphWrapper); + // KEEP_MAPS(Parent, ErasingFirstGraphWrapper); }; ///@} diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/list_graph.h --- a/src/hugo/list_graph.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/list_graph.h Mon Sep 20 22:57:48 2004 +0000 @@ -442,9 +442,6 @@ typedef SymListGraph Graph; - /// Importing maps from the base class ListGraph. - KEEP_MAPS(ListGraph, SymListGraph); - /// Creating symmetric map registry. CREATE_SYM_EDGE_MAP_REGISTRY; /// Creating symmetric edge map. diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/map_defines.h --- a/src/hugo/map_defines.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/map_defines.h Mon Sep 20 22:57:48 2004 +0000 @@ -38,21 +38,24 @@ #define CREATE_NODE_MAP(DynMap) \ template \ class NodeMap : public DynMap { \ -typedef DynMap MapImpl; \ public: \ +typedef DynMap Parent; \ NodeMap() {} \ -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(const typename Parent::Graph& g) \ + : Parent(g, g.node_maps) {} \ +NodeMap(const typename Parent::Graph& g, const Value& v) \ + : Parent(g, g.node_maps, v) {} \ +NodeMap(const NodeMap& copy) : Parent(static_cast(copy)) {} \ +template \ +NodeMap(const NodeMap& copy) \ + : Parent(static_cast::Parent&>(copy)) {} \ NodeMap& operator=(const NodeMap& copy) { \ - MapImpl::operator=(static_cast(copy));\ + Parent::operator=(static_cast(copy));\ return *this; \ } \ -template NodeMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy);\ +template \ +NodeMap& operator=(const NodeMap& copy) { \ + Parent::operator=(static_cast::Parent&>(copy));\ return *this; \ } \ }; @@ -66,21 +69,25 @@ #define CREATE_EDGE_MAP(DynMap) \ template \ class EdgeMap : public DynMap { \ -typedef DynMap MapImpl; \ public: \ +typedef DynMap Parent; \ +\ EdgeMap() {} \ -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(const typename Parent::Graph& g) \ + : Parent(g, g.edge_maps) {} \ +EdgeMap(const typename Parent::Graph& g, const Value& v) \ + : Parent(g, g.edge_maps, v) {} \ +EdgeMap(const EdgeMap& copy) : Parent(static_cast(copy)) {} \ +template \ +EdgeMap(const EdgeMap& copy) \ + : Parent(static_cast::Parent&>(copy)) {} \ EdgeMap& operator=(const EdgeMap& copy) { \ - MapImpl::operator=(static_cast(copy));\ + Parent::operator=(static_cast(copy));\ return *this; \ } \ -template EdgeMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy);\ +template \ +EdgeMap& operator=(const EdgeMap& copy) { \ + Parent::operator=(static_cast::Parent&>(copy));\ return *this; \ } \ }; @@ -108,101 +115,88 @@ #define CREATE_SYM_EDGE_MAP(DynMap) \ template \ class SymEdgeMap : public SymMap { \ - typedef SymMap MapImpl; \ - public: \ +public: \ +typedef SymMap Parent; \ \ - 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; \ - } \ +SymEdgeMap() {} \ +SymEdgeMap(const typename Parent::Graph& g) \ + : Parent(g, g.sym_edge_maps) {} \ +SymEdgeMap(const typename Parent::Graph& g, const Value& v) \ + : Parent(g, g.sym_edge_maps, v) {} \ +SymEdgeMap(const SymEdgeMap& copy) \ + : Parent(static_cast(copy)) {} \ +template \ +SymEdgeMap(const NodeMap& copy) \ + : Parent(static_cast::Parent&>(copy)) {} \ +SymEdgeMap& operator=(const SymEdgeMap& copy) { \ + Parent::operator=(static_cast(copy));\ + return *this; \ +} \ +template \ +SymEdgeMap& operator=(const SymEdgeMap& copy) { \ + Parent::operator=(static_cast::Parent&>(copy));\ + return *this; \ +} \ }; - /** 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() {} \ +class NodeMap : public From::template NodeMap { \ \ - NodeMap(const To& to) \ - : MapImpl(static_cast(from)) { } \ +public: \ +typedef typename From::template NodeMap Parent; \ \ - NodeMap(const To& to, const Value& value) \ - : MapImpl(static_cast(from), 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; \ - } \ +NodeMap() : Parent() {} \ +NodeMap(const To& to) \ + : Parent(static_cast(from)) { } \ +NodeMap(const To& to, const Value& value) \ + : Parent(static_cast(from), value) { } \ +NodeMap(const NodeMap& copy) \ + : Parent(static_cast(copy)) {} \ +template \ +NodeMap(const NodeMap& copy) \ + : Parent(static_cast::Parent&>(copy)) {} \ +NodeMap& operator=(const NodeMap& copy) { \ + Parent::operator=(static_cast(copy)); \ + return *this; \ +} \ +template \ +NodeMap& operator=(const NodeMap& copy) { \ + Parent::operator=(static_cast::Parent&>(copy));\ + return *this; \ +} \ }; /** 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() {} \ +class EdgeMap : public From::template EdgeMap { \ \ - EdgeMap(const To& to) \ - : MapImpl(static_cast(from)) { } \ +public: \ +typedef typename From::template EdgeMap Parent; \ \ - EdgeMap(const To& to, const Value& value) \ - : MapImpl(static_cast(from), value) { } \ -\ - EdgeMap(const EdgeMap& copy) \ - : MapImpl(static_cast(copy)) {} \ -\ - template \ - EdgeMap(const CMap& copy) \ - : MapImpl(copy) {} \ -\ - EdgeMap& operator=(const EdgeMap& copy) { \ - MapImpl::operator=(static_cast(copy)); \ - return *this; \ - } \ -\ - template \ - EdgeMap& operator=(const CMap& copy) { \ - MapImpl::operator=(copy); \ - return *this; \ - } \ +EdgeMap() : Parent() {} \ +EdgeMap(const To& to) \ + : Parent(static_cast(from)) { } \ +EdgeMap(const To& to, const Value& value) \ + : Parent(static_cast(from), value) { } \ +EdgeMap(const EdgeMap& copy) \ + : Parent(static_cast(copy)) {} \ +template \ +EdgeMap(const EdgeMap& copy) \ + : Parent(static_cast::Parent&>(copy)) {} \ +EdgeMap& operator=(const EdgeMap& copy) { \ + Parent::operator=(static_cast(copy)); \ + return *this; \ +} \ +template \ +EdgeMap& operator=(const EdgeMap& copy) { \ + Parent::operator=(static_cast::Parent&>(copy));\ + return *this; \ +} \ }; #define KEEP_EDGE_MAP(From, To) \ diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/map_registry.h --- a/src/hugo/map_registry.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/map_registry.h Mon Sep 20 22:57:48 2004 +0000 @@ -70,7 +70,6 @@ /** * Assign operator. */ - const MapBase& operator=(const MapBase& copy) { if (registry) { registry->detach(*this); diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/smart_graph.h --- a/src/hugo/smart_graph.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/smart_graph.h Mon Sep 20 22:57:48 2004 +0000 @@ -317,9 +317,6 @@ public: typedef SymSmartGraph Graph; - /// Importing maps from the base class ListGraph. - KEEP_MAPS(SmartGraph, SymSmartGraph); - /// Creating symmetric map registry. CREATE_SYM_EDGE_MAP_REGISTRY; /// Creating symmetric edge map. diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/sym_map.h --- a/src/hugo/sym_map.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/sym_map.h Mon Sep 20 22:57:48 2004 +0000 @@ -103,11 +103,6 @@ SymMap(const SymMap& copy) : MapImpl(static_cast(copy)) {} - /** Constructor to copy a map of an other map type. - */ - template SymMap(const CMap& copy) - : MapImpl(copy) {} - /** Assign operator to copy a map of the same map type. */ SymMap& operator=(const SymMap& copy) { @@ -115,13 +110,6 @@ return *this; } - /** Assign operator to copy a map of an other map type. - */ - template SymMap& operator=(const CMap& copy) { - MapImpl::operator=(copy); - return *this; - } - /** Add a new key to the map. It called by the map registry. */ void add(const KeyType& key) { diff -r 3a48bc350e0f -r 74589d20dbc3 src/hugo/vector_map.h --- a/src/hugo/vector_map.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/hugo/vector_map.h Mon Sep 20 22:57:48 2004 +0000 @@ -32,6 +32,7 @@ template class VectorMap : public MapRegistry::MapBase { + template friend class VectorMap; public: /// The graph type of the maps. @@ -82,36 +83,29 @@ VectorMap(const Graph& g, MapRegistry& r, const Value& v) : MapBase(g, r), container(KeyInfo::maxId(g)+1, v) {} - /** Constructor to copy a map of an other map type. + /** Assign operator to copy a map of an other map type. */ - template VectorMap(const CMap& copy) : MapBase(copy) { - if (MapBase::getGraph()) { - container.resize(KeyInfo::maxId(*MapBase::getGraph())+1); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - set(it, copy[it]); - } + template + VectorMap(const VectorMap& c) + : MapBase(c), container(c.container.size()) { + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = KeyInfo::id(*MapBase::getGraph(), it); + container[id] = c.container[id]; } } - /** Assign operator to copy a map an other map type. + /** Assign operator to copy a map of an other map type. */ - template VectorMap& operator=(const CMap& copy) { - container.clear(); - this->MapBase::operator=(copy); - if (MapBase::getGraph()) { - container.resize(KeyInfo::maxId(*MapBase::getGraph())+1); - for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { - set(it, copy[it]); - } + template + VectorMap& operator=(const VectorMap& c) { + container.resize(c.container.size()); + MapBase::operator=(c); + for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) { + int id = KeyInfo::id(*MapBase::getGraph(), it); + container[id] = c.container[id]; } return *this; } - - /** The destructor of the map. - */ - virtual ~VectorMap() { - } - /** * The subscript operator. The map can be subscripted by the * actual keys of the graph. diff -r 3a48bc350e0f -r 74589d20dbc3 src/test/graph_test.h --- a/src/test/graph_test.h Mon Sep 20 17:53:33 2004 +0000 +++ b/src/test/graph_test.h Mon Sep 20 22:57:48 2004 +0000 @@ -1,3 +1,4 @@ +// -*- c++ -*- #ifndef HUGO_TEST_GRAPH_TEST_H #define HUGO_TEST_GRAPH_TEST_H @@ -9,289 +10,299 @@ //! \brief Some utility to test graph classes. namespace hugo { + struct DummyType { + int value; + DummyType() {} + DummyType(int p) : value(p) {} + DummyType& operator=(int p) { value = p; return *this;} + }; -template void checkCompileStaticGraph(Graph &G) -{ - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::Edge Edge; - typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::InEdgeIt InEdgeIt; - typedef typename Graph::OutEdgeIt OutEdgeIt; + + template void checkCompileStaticGraph(Graph &G) + { + typedef typename Graph::Node Node; + typedef typename Graph::NodeIt NodeIt; + typedef typename Graph::Edge Edge; + typedef typename Graph::EdgeIt EdgeIt; + typedef typename Graph::InEdgeIt InEdgeIt; + typedef typename Graph::OutEdgeIt OutEdgeIt; - { - Node i; Node j(i); Node k(INVALID); - i=j; - bool b; b=true; - b=(i==INVALID); b=(i!=INVALID); - b=(i==j); b=(i!=j); b=(iNodeIt conversion - NodeIt ni(G,n); - } - { - Edge i; Edge j(i); Edge k(INVALID); - i=j; - bool b; b=true; - b=(i==INVALID); b=(i!=INVALID); - b=(i==j); b=(i!=j); b=(iEdgeIt conversion - EdgeIt ei(G,e); - } - { - Node n; - InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n); - i=j; - j=G.first(i,n); - j=++i; - bool b; b=true; - b=(i==INVALID); b=(i!=INVALID); - Edge e(i); - e=i; - b=(i==j); b=(i!=j); b=(iInEdgeIt conversion - InEdgeIt ei(G,e); - } - { - Node n; - OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n); - i=j; - j=G.first(i,n); - j=++i; - bool b; b=true; - b=(i==INVALID); b=(i!=INVALID); - Edge e(i); - e=i; - b=(i==j); b=(i!=j); b=(iOutEdgeIt conversion - OutEdgeIt ei(G,e); - } - { - Node n,m; - n=m=INVALID; - Edge e; - e=INVALID; - n=G.tail(e); - n=G.head(e); - } - // id tests - { Node n; int i=G.id(n); i=i; } - { Edge e; int i=G.id(e); i=i; } - //NodeMap tests - { - Node k; - typename Graph::template NodeMap m(G); - //Const map - typename Graph::template NodeMap const &cm = m; - //Inicialize with default value - typename Graph::template NodeMap mdef(G,12); - //Copy - typename Graph::template NodeMap mm(cm); - //Copy from another type - typename Graph::template NodeMap dm(cm); - int v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; + { + Node i; Node j(i); Node k(INVALID); + i=j; + bool b; b=true; + b=(i==INVALID); b=(i!=INVALID); + b=(i==j); b=(i!=j); b=(iNodeIt conversion + NodeIt ni(G,n); + } + { + Edge i; Edge j(i); Edge k(INVALID); + i=j; + bool b; b=true; + b=(i==INVALID); b=(i!=INVALID); + b=(i==j); b=(i!=j); b=(iEdgeIt conversion + EdgeIt ei(G,e); + } + { + Node n; + InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n); + i=j; + j=G.first(i,n); + j=++i; + bool b; b=true; + b=(i==INVALID); b=(i!=INVALID); + Edge e(i); + e=i; + b=(i==j); b=(i!=j); b=(iInEdgeIt conversion + InEdgeIt ei(G,e); + } + { + Node n; + OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n); + i=j; + j=G.first(i,n); + j=++i; + bool b; b=true; + b=(i==INVALID); b=(i!=INVALID); + Edge e(i); + e=i; + b=(i==j); b=(i!=j); b=(iOutEdgeIt conversion + OutEdgeIt ei(G,e); + } + { + Node n,m; + n=m=INVALID; + Edge e; + e=INVALID; + n=G.tail(e); + n=G.head(e); + } + // id tests + { Node n; int i=G.id(n); i=i; } + { Edge e; int i=G.id(e); i=i; } + //NodeMap tests + { + Node k; + typename Graph::template NodeMap m(G); + //Const map + typename Graph::template NodeMap const &cm = m; + //Inicialize with default value + typename Graph::template NodeMap mdef(G,12); + //Copy + typename Graph::template NodeMap mm(cm); + //Copy from another type + typename Graph::template NodeMap dm(cm); + //Copy to more complex type + typename Graph::template NodeMap em(cm); + int v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; - m=cm; - dm=cm; //Copy from another type + m=cm; + dm=cm; //Copy from another type + em=cm; //Copy to more complex type + { + //Check the typedef's + typename Graph::template NodeMap::ValueType val; + val=1; + typename Graph::template NodeMap::KeyType key; + key = typename Graph::NodeIt(G); + } + } + { //bool NodeMap + Node k; + typename Graph::template NodeMap m(G); + typename Graph::template NodeMap const &cm = m; //Const map + //Inicialize with default value + typename Graph::template NodeMap mdef(G,12); + typename Graph::template NodeMap mm(cm); //Copy + typename Graph::template NodeMap dm(cm); //Copy from another type + bool v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + m=dm; //Copy to another type + + { + //Check the typedef's + typename Graph::template NodeMap::ValueType val; + val=true; + typename Graph::template NodeMap::KeyType key; + key= typename Graph::NodeIt(G); + } + } + //EdgeMap tests + { + Edge k; + typename Graph::template EdgeMap m(G); + typename Graph::template EdgeMap const &cm = m; //Const map + //Inicialize with default value + typename Graph::template EdgeMap mdef(G,12); + typename Graph::template EdgeMap mm(cm); //Copy + typename Graph::template EdgeMap dm(cm); //Copy from another type + int v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + { + //Check the typedef's + typename Graph::template EdgeMap::ValueType val; + val=1; + typename Graph::template EdgeMap::KeyType key; + key= typename Graph::EdgeIt(G); + } + } + { //bool EdgeMap + Edge k; + typename Graph::template EdgeMap m(G); + typename Graph::template EdgeMap const &cm = m; //Const map + //Inicialize with default value + typename Graph::template EdgeMap mdef(G,12); + typename Graph::template EdgeMap mm(cm); //Copy + typename Graph::template EdgeMap dm(cm); //Copy from another type + bool v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + m=dm; //Copy to another type + { + //Check the typedef's + typename Graph::template EdgeMap::ValueType val; + val=true; + typename Graph::template EdgeMap::KeyType key; + key= typename Graph::EdgeIt(G); + } + } + } + + template void checkCompileGraph(Graph &G) { - //Check the typedef's - typename Graph::template NodeMap::ValueType val; - val=1; - typename Graph::template NodeMap::KeyType key; - key = typename Graph::NodeIt(G); + checkCompileStaticGraph(G); + + typedef typename Graph::Node Node; + typedef typename Graph::NodeIt NodeIt; + typedef typename Graph::Edge Edge; + typedef typename Graph::EdgeIt EdgeIt; + typedef typename Graph::InEdgeIt InEdgeIt; + typedef typename Graph::OutEdgeIt OutEdgeIt; + + Node n,m; + n=G.addNode(); + m=G.addNode(); + Edge e; + e=G.addEdge(n,m); + + // G.clear(); } - } - { //bool NodeMap - Node k; - typename Graph::template NodeMap m(G); - typename Graph::template NodeMap const &cm = m; //Const map - //Inicialize with default value - typename Graph::template NodeMap mdef(G,12); - typename Graph::template NodeMap mm(cm); //Copy - typename Graph::template NodeMap dm(cm); //Copy from another type - bool v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type - m=dm; //Copy to another type + template void checkCompileGraphEraseEdge(Graph &G) { - //Check the typedef's - typename Graph::template NodeMap::ValueType val; - val=true; - typename Graph::template NodeMap::KeyType key; - key= typename Graph::NodeIt(G); + typename Graph::Edge e; + G.erase(e); } - } - //EdgeMap tests - { - Edge k; - typename Graph::template EdgeMap m(G); - typename Graph::template EdgeMap const &cm = m; //Const map - //Inicialize with default value - typename Graph::template EdgeMap mdef(G,12); - typename Graph::template EdgeMap mm(cm); //Copy - typename Graph::template EdgeMap dm(cm); //Copy from another type - int v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type + + template void checkCompileGraphEraseNode(Graph &G) { - //Check the typedef's - typename Graph::template EdgeMap::ValueType val; - val=1; - typename Graph::template EdgeMap::KeyType key; - key= typename Graph::EdgeIt(G); + typename Graph::Node n; + G.erase(n); } - } - { //bool EdgeMap - Edge k; - typename Graph::template EdgeMap m(G); - typename Graph::template EdgeMap const &cm = m; //Const map - //Inicialize with default value - typename Graph::template EdgeMap mdef(G,12); - typename Graph::template EdgeMap mm(cm); //Copy - typename Graph::template EdgeMap dm(cm); //Copy from another type - bool v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type - m=dm; //Copy to another type + + template void checkCompileErasableGraph(Graph &G) { - //Check the typedef's - typename Graph::template EdgeMap::ValueType val; - val=true; - typename Graph::template EdgeMap::KeyType key; - key= typename Graph::EdgeIt(G); + checkCompileGraph(G); + checkCompileGraphEraseNode(G); + checkCompileGraphEraseEdge(G); } - } -} -template void checkCompileGraph(Graph &G) -{ - checkCompileStaticGraph(G); + template void checkCompileGraphFindEdge(Graph &G) + { + typedef typename Graph::NodeIt Node; + typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::Edge Edge; - typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::InEdgeIt InEdgeIt; - typedef typename Graph::OutEdgeIt OutEdgeIt; - - Node n,m; - n=G.addNode(); - m=G.addNode(); - Edge e; - e=G.addEdge(n,m); - - // G.clear(); -} + G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G))); + G.findEdge(Node(),Node(),G.findEdge(Node(),Node())); + } -template void checkCompileGraphEraseEdge(Graph &G) -{ - typename Graph::Edge e; - G.erase(e); -} + template void checkGraphNodeList(Graph &G, int nn) + { + typename Graph::NodeIt n(G); + for(int i=0;i void checkCompileGraphEraseNode(Graph &G) -{ - typename Graph::Node n; - G.erase(n); -} + template void checkGraphEdgeList(Graph &G, int nn) + { + typedef typename Graph::EdgeIt EdgeIt; -template void checkCompileErasableGraph(Graph &G) -{ - checkCompileGraph(G); - checkCompileGraphEraseNode(G); - checkCompileGraphEraseEdge(G); -} + EdgeIt e(G); + for(int i=0;i void checkCompileGraphFindEdge(Graph &G) -{ - typedef typename Graph::NodeIt Node; - typedef typename Graph::NodeIt NodeIt; + template void checkGraphOutEdgeList(Graph &G, + typename Graph::Node n, + int nn) + { + typename Graph::OutEdgeIt e(G,n); + for(int i=0;i void checkGraphInEdgeList(Graph &G, + typename Graph::Node n, + int nn) + { + typename Graph::InEdgeIt e(G,n); + for(int i=0;i void checkGraphNodeList(Graph &G, int nn) -{ - typename Graph::NodeIt n(G); - for(int i=0;i void checkGraphEdgeList(Graph &G, int nn) -{ - typedef typename Graph::EdgeIt EdgeIt; - - EdgeIt e(G); - for(int i=0;i void checkGraphOutEdgeList(Graph &G, - typename Graph::Node n, - int nn) -{ - typename Graph::OutEdgeIt e(G,n); - for(int i=0;i void checkGraphInEdgeList(Graph &G, - typename Graph::Node n, - int nn) -{ - typename Graph::InEdgeIt e(G,n); - for(int i=0;i GW; template void checkCompileStaticGraph(GW &); -//template void checkCompileGraphFindEdge(SmartGraph &); -//Compile SymSmartGraph +//Compile RevGraphWrapper typedef RevGraphWrapper RevGW; template void checkCompileStaticGraph(RevGW &); -//template void checkCompileGraphFindEdge(SymSmartGraph &); + +//Compile SubGraphWrapper +typedef SubGraphWrapper, + Graph::EdgeMap > SubGW; +template void checkCompileStaticGraph(SubGW &); + +//Compile UndirGraphWrapper +/// \bug UndirGraphWrapper cannot pass the StaticGraph test +//typedef UndirGraphWrapper UndirGW; +//template void checkCompileStaticGraph(UndirGW &); + +//Compile UndirGraph +//typedef UndirGraph UndirG; +//template void checkCompileStaticGraph(UndirG &); + +//typedef SubBidirGraphWrapper, +/// \bug SubBidirGraphWrapper cannot pass the StaticGraph test +// Graph::EdgeMap > SubBDGW; +//template void checkCompileStaticGraph(SubBDGW &); + +//Compile BidirGraphWrapper +//typedef BidirGraphWrapper BidirGW; +//template void checkCompileStaticGraph(BidirGW &); + +//Compile BidirGraph +//typedef BidirGraph BidirG; +//template void checkCompileStaticGraph(BidirG &); + +//Compile ResGraphWrapper +//typedef ResGraphWrapper, +// Graph::EdgeMap > ResGW; +//template void checkCompileStaticGraph(ResGW &); + +//Compile ErasingFirstGraphWrapper +typedef ErasingFirstGraphWrapper > ErasingFirstGW; +template void checkCompileStaticGraph(ErasingFirstGW &); int main()