template<typename CMap> Map(const CMap&) like constructors and
authordeba
Mon, 20 Sep 2004 22:57:48 +0000
changeset 89174589d20dbc3
parent 890 3a48bc350e0f
child 892 004636791dd7
template<typename CMap> Map(const CMap&) like constructors and
assigns are removed.
src/hugo/array_map.h
src/hugo/default_map.h
src/hugo/graph_wrapper.h
src/hugo/list_graph.h
src/hugo/map_defines.h
src/hugo/map_registry.h
src/hugo/smart_graph.h
src/hugo/sym_map.h
src/hugo/vector_map.h
src/test/graph_test.h
src/test/graph_wrapper_test.cc
     1.1 --- a/src/hugo/array_map.h	Mon Sep 20 17:53:33 2004 +0000
     1.2 +++ b/src/hugo/array_map.h	Mon Sep 20 22:57:48 2004 +0000
     1.3 @@ -65,7 +65,7 @@
     1.4  	
     1.5      /** Default constructor for the map.
     1.6       */
     1.7 -    ArrayMap() : values(0), capacity(0) {}
     1.8 +    ArrayMap() : capacity(0), values(0) {}
     1.9  			
    1.10      /** Graph and Registry initialized map constructor.
    1.11       */
    1.12 @@ -90,7 +90,7 @@
    1.13  
    1.14      /** Constructor to copy a map of the same map type.
    1.15       */
    1.16 -    ArrayMap(const ArrayMap& copy) : MapBase(*copy.graph, *copy.registry) {
    1.17 +    ArrayMap(const ArrayMap& copy) : MapBase(copy) {
    1.18        capacity = copy.capacity;
    1.19        if (capacity == 0) return;
    1.20        values = allocator.allocate(capacity);
    1.21 @@ -102,13 +102,15 @@
    1.22  
    1.23      /** Constructor to copy a map of an other map type.
    1.24       */
    1.25 -    template <typename CMap> ArrayMap(const CMap& copy) 
    1.26 -      : MapBase(copy), capacity(0), values(0) {
    1.27 -      if (MapBase::getGraph()) {
    1.28 -	allocate_memory();
    1.29 -	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    1.30 -	  set(it, copy[it]);
    1.31 -	}
    1.32 +    template <typename TT>
    1.33 +    ArrayMap(const ArrayMap<MapRegistry, TT>& copy) 
    1.34 +      : MapBase(copy) {
    1.35 +      capacity = copy.capacity;
    1.36 +      if (capacity == 0) return;
    1.37 +      values = allocator.allocate(capacity);
    1.38 +      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    1.39 +	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
    1.40 +	allocator.construct(&(values[id]), copy.values[id]);
    1.41        }
    1.42      }
    1.43  
    1.44 @@ -116,34 +118,46 @@
    1.45       */
    1.46      ArrayMap& operator=(const ArrayMap& copy) {
    1.47        if (&copy == this) return *this;
    1.48 +
    1.49        if (capacity != 0) {
    1.50  	MapBase::destroy();
    1.51  	allocator.deallocate(values, capacity);
    1.52        }
    1.53 +
    1.54 +      MapBase::operator=(copy);
    1.55 +
    1.56        capacity = copy.capacity;
    1.57        if (capacity == 0) return *this;
    1.58        values = allocator.allocate(capacity);
    1.59 +
    1.60        for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    1.61  	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
    1.62  	allocator.construct(&(values[id]), copy.values[id]);
    1.63        }
    1.64 +
    1.65        return *this;
    1.66      }
    1.67  
    1.68 -    /** Assign operator to copy a map an other map type.
    1.69 +    /** Assign operator to copy a map of an other map type.
    1.70       */
    1.71 -    template <typename CMap> ArrayMap& operator=(const CMap& copy) {
    1.72 +    template <typename TT>
    1.73 +    ArrayMap& operator=(const ArrayMap<MapRegistry, TT>& copy) {
    1.74        if (capacity != 0) {
    1.75  	MapBase::destroy();
    1.76  	allocator.deallocate(values, capacity);
    1.77        }
    1.78 +
    1.79        MapBase::operator=(copy);
    1.80 -      if (MapBase::getGraph()) {
    1.81 -	allocate_memory();
    1.82 -	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    1.83 -	  set(it, copy[it]);
    1.84 -	}
    1.85 +
    1.86 +      capacity = copy.capacity;
    1.87 +      if (capacity == 0) return *this;
    1.88 +      values = allocator.allocate(capacity);
    1.89 +
    1.90 +      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    1.91 +	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
    1.92 +	allocator.construct(&(values[id]), copy.values[id]);
    1.93        }
    1.94 +
    1.95        return *this;
    1.96      }
    1.97  				
     2.1 --- a/src/hugo/default_map.h	Mon Sep 20 17:53:33 2004 +0000
     2.2 +++ b/src/hugo/default_map.h	Mon Sep 20 22:57:48 2004 +0000
     2.3 @@ -29,36 +29,48 @@
     2.4    /** Macro to implement the DefaultMap.
     2.5     */
     2.6  #define DEFAULT_MAP_BODY(DynMap, Value) \
     2.7 -  { \
     2.8 -    typedef DynMap<MapRegistry, Value> MapImpl; \
     2.9 -  \
    2.10 -  public: \
    2.11 -  \
    2.12 -    typedef typename MapRegistry::Graph Graph; \
    2.13 -  \
    2.14 -    DefaultMap() : MapImpl() {} \
    2.15 -  \
    2.16 -    DefaultMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {} \
    2.17 -  \
    2.18 -    DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
    2.19 -      : MapImpl(g, r, v) {} \
    2.20 -  \
    2.21 -    DefaultMap(const DefaultMap& copy) \
    2.22 -      : MapImpl(static_cast<const MapImpl&>(copy)) {} \
    2.23 -  \
    2.24 -    template <typename CMap> DefaultMap(const CMap& copy) : MapImpl(copy) {} \
    2.25 -  \
    2.26 -    DefaultMap& operator=(const DefaultMap& copy) { \
    2.27 -      MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
    2.28 -      return *this; \
    2.29 +{ \
    2.30 +\
    2.31 +public: \
    2.32 +\
    2.33 +typedef DynMap<MapRegistry, Value> Parent; \
    2.34 +\
    2.35 +typedef typename MapRegistry::Graph Graph; \
    2.36 +\
    2.37 +DefaultMap() : Parent() {} \
    2.38 +DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
    2.39 +DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
    2.40 +  : Parent(g, r, v) {} \
    2.41 +DefaultMap(const DefaultMap& copy) \
    2.42 +  : Parent(static_cast<const Parent&>(copy)) {} \
    2.43 +template <typename TT> \
    2.44 +DefaultMap(const DefaultMap<MapRegistry, TT>& copy) { \
    2.45 +  Parent::MapBase::operator= \
    2.46 +    (static_cast<const typename Parent::MapBase&>(copy)); \
    2.47 +  if (Parent::getGraph()) { \
    2.48 +    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    2.49 +      Parent::add(it); \
    2.50 +      Parent::operator[](it) = copy[it]; \
    2.51      } \
    2.52 -  \
    2.53 -    template <typename CMap> DefaultMap& operator=(const CMap& copy) { \
    2.54 -      MapImpl::operator=(copy); \
    2.55 -      return *this; \
    2.56 +  } \
    2.57 +} \
    2.58 +DefaultMap& operator=(const DefaultMap& copy) { \
    2.59 +  Parent::operator=(static_cast<const Parent&>(copy)); \
    2.60 +  return *this; \
    2.61 +} \
    2.62 +template <typename TT> \
    2.63 +DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
    2.64 +  Parent::clear(); \
    2.65 +  Parent::MapBase::operator=(copy); \
    2.66 +  if (Parent::getGraph()) { \
    2.67 +    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
    2.68 +      Parent::add(it); \
    2.69 +      Parent::operator[](it) = copy[it]; \
    2.70      } \
    2.71 -  \
    2.72 -  };
    2.73 +  } \
    2.74 +  return *this; \
    2.75 +} \
    2.76 +};
    2.77  
    2.78  
    2.79    template <typename MapRegistry, typename Type>
     3.1 --- a/src/hugo/graph_wrapper.h	Mon Sep 20 17:53:33 2004 +0000
     3.2 +++ b/src/hugo/graph_wrapper.h	Mon Sep 20 22:57:48 2004 +0000
     3.3 @@ -286,7 +286,7 @@
     3.4      Node head(const Edge& e) const { 
     3.5        return GraphWrapper<Graph>::tail(e); }
     3.6  
     3.7 -    KEEP_MAPS(Parent, RevGraphWrapper);
     3.8 +    //    KEEP_MAPS(Parent, RevGraphWrapper);
     3.9  
    3.10    };
    3.11  
    3.12 @@ -493,7 +493,7 @@
    3.13        return i; 
    3.14      }
    3.15  
    3.16 -    KEEP_MAPS(Parent, SubGraphWrapper);
    3.17 +    //    KEEP_MAPS(Parent, SubGraphWrapper);
    3.18    };
    3.19  
    3.20  
    3.21 @@ -558,14 +558,14 @@
    3.22        if (e.out_or_in) return this->graph->head(e); else 
    3.23  	return this->graph->tail(e); }
    3.24  
    3.25 -    KEEP_MAPS(Parent, UndirGraphWrapper);
    3.26 +    //    KEEP_MAPS(Parent, UndirGraphWrapper);
    3.27  
    3.28    };
    3.29    
    3.30    /// \brief An undirected graph template.
    3.31    ///
    3.32    ///\warning Graph wrappers are in even more experimental state than the other
    3.33 -  ///parts of the lib. Use them at you own risk.
    3.34 +  ///parts of the lib. Use them at your own risk.
    3.35    ///
    3.36    /// An undirected graph template.
    3.37    /// This class works as an undirected graph and a directed graph of 
    3.38 @@ -581,7 +581,7 @@
    3.39        Parent::setGraph(gr); 
    3.40      }
    3.41  
    3.42 -    KEEP_MAPS(Parent, UndirGraph);
    3.43 +    //    KEEP_MAPS(Parent, UndirGraph);
    3.44    };
    3.45  
    3.46  
    3.47 @@ -894,28 +894,54 @@
    3.48      /// Graph::EdgeMap one for the forward edges and 
    3.49      /// one for the backward edges.
    3.50      class EdgeMap {
    3.51 +      template <typename TT> friend class EdgeMap;
    3.52        typename Graph::template EdgeMap<T> forward_map, backward_map; 
    3.53      public:
    3.54        typedef T ValueType;
    3.55        typedef Edge KeyType;
    3.56 +
    3.57        EdgeMap(const SubBidirGraphWrapper<Graph, 
    3.58  	      ForwardFilterMap, BackwardFilterMap>& g) : 
    3.59  	forward_map(*(g.graph)), backward_map(*(g.graph)) { }
    3.60 +
    3.61        EdgeMap(const SubBidirGraphWrapper<Graph, 
    3.62  	      ForwardFilterMap, BackwardFilterMap>& g, T a) : 
    3.63  	forward_map(*(g.graph), a), backward_map(*(g.graph), a) { }
    3.64 +
    3.65 +      template <typename TT>
    3.66 +      EdgeMap(const EdgeMap<TT>& copy) 
    3.67 +	: forward_map(copy.forward_map), backward_map(copy.backward_map) {}
    3.68 +
    3.69 +      template <typename TT>
    3.70 +      EdgeMap& operator=(const EdgeMap<TT>& copy) {
    3.71 +	forward_map = copy.forward_map;
    3.72 +	backward_map = copy.backward_map;
    3.73 +	return *this;
    3.74 +      }
    3.75 +      
    3.76        void set(Edge e, T a) { 
    3.77  	if (!e.backward) 
    3.78  	  forward_map.set(e, a); 
    3.79  	else 
    3.80  	  backward_map.set(e, a); 
    3.81        }
    3.82 -      T operator[](Edge e) const { 
    3.83 +
    3.84 +      typename Graph::template EdgeMap<T>::ConstReferenceType 
    3.85 +      operator[](Edge e) const { 
    3.86  	if (!e.backward) 
    3.87  	  return forward_map[e]; 
    3.88  	else 
    3.89  	  return backward_map[e]; 
    3.90        }
    3.91 +
    3.92 +      typename Graph::template EdgeMap<T>::ReferenceType 
    3.93 +      operator[](Edge e) { 
    3.94 +	if (!e.backward) 
    3.95 +	  return forward_map[e]; 
    3.96 +	else 
    3.97 +	  return backward_map[e]; 
    3.98 +      }
    3.99 +
   3.100        void update() { 
   3.101  	forward_map.update(); 
   3.102  	backward_map.update();
   3.103 @@ -923,7 +949,7 @@
   3.104      };
   3.105  
   3.106  
   3.107 -    KEEP_NODE_MAP(Parent, SubBidirGraphWrapper);
   3.108 +    //    KEEP_NODE_MAP(Parent, SubBidirGraphWrapper);
   3.109  
   3.110    };
   3.111  
   3.112 @@ -965,7 +991,7 @@
   3.113      int edgeNum() const { 
   3.114        return 2*this->graph->edgeNum();
   3.115      }
   3.116 -    KEEP_MAPS(Parent, BidirGraphWrapper);
   3.117 +    //    KEEP_MAPS(Parent, BidirGraphWrapper);
   3.118    };
   3.119  
   3.120  
   3.121 @@ -991,7 +1017,7 @@
   3.122      BidirGraph() : BidirGraphWrapper<Graph>() { 
   3.123        Parent::setGraph(gr); 
   3.124      }
   3.125 -    KEEP_MAPS(Parent, BidirGraph);
   3.126 +    //    KEEP_MAPS(Parent, BidirGraph);
   3.127    };
   3.128  
   3.129  
   3.130 @@ -1106,7 +1132,7 @@
   3.131        }
   3.132      };
   3.133  
   3.134 -    KEEP_MAPS(Parent, ResGraphWrapper);
   3.135 +    //    KEEP_MAPS(Parent, ResGraphWrapper);
   3.136    };
   3.137  
   3.138  
   3.139 @@ -1168,7 +1194,7 @@
   3.140        first_out_edges->set(n, f);
   3.141      }
   3.142  
   3.143 -    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
   3.144 +    //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
   3.145    };
   3.146  
   3.147    ///@}
     4.1 --- a/src/hugo/list_graph.h	Mon Sep 20 17:53:33 2004 +0000
     4.2 +++ b/src/hugo/list_graph.h	Mon Sep 20 22:57:48 2004 +0000
     4.3 @@ -442,9 +442,6 @@
     4.4  
     4.5      typedef SymListGraph Graph;
     4.6  
     4.7 -    /// Importing maps from the base class ListGraph.
     4.8 -    KEEP_MAPS(ListGraph, SymListGraph);
     4.9 -
    4.10      /// Creating symmetric map registry.
    4.11      CREATE_SYM_EDGE_MAP_REGISTRY;
    4.12      /// Creating symmetric edge map.
     5.1 --- a/src/hugo/map_defines.h	Mon Sep 20 17:53:33 2004 +0000
     5.2 +++ b/src/hugo/map_defines.h	Mon Sep 20 22:57:48 2004 +0000
     5.3 @@ -38,21 +38,24 @@
     5.4  #define CREATE_NODE_MAP(DynMap) \
     5.5  template <typename Value> \
     5.6  class NodeMap : public DynMap<NodeMapRegistry, Value> { \
     5.7 -typedef DynMap<NodeMapRegistry, Value> MapImpl; \
     5.8  public: \
     5.9 +typedef DynMap<NodeMapRegistry, Value> Parent; \
    5.10  NodeMap() {} \
    5.11 -NodeMap(const typename MapImpl::Graph& g) \
    5.12 -  : MapImpl(g, g.node_maps) {} \
    5.13 -NodeMap(const typename MapImpl::Graph& g, const Value& v) \
    5.14 -  : MapImpl(g, g.node_maps, v) {} \
    5.15 -NodeMap(const NodeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
    5.16 -template <typename CMap> NodeMap(const CMap& copy) : MapImpl(copy) {} \
    5.17 +NodeMap(const typename Parent::Graph& g) \
    5.18 +  : Parent(g, g.node_maps) {} \
    5.19 +NodeMap(const typename Parent::Graph& g, const Value& v) \
    5.20 +  : Parent(g, g.node_maps, v) {} \
    5.21 +NodeMap(const NodeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
    5.22 +template <typename TT> \
    5.23 +NodeMap(const NodeMap<TT>& copy) \
    5.24 +  : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
    5.25  NodeMap& operator=(const NodeMap& copy) { \
    5.26 -  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
    5.27 +  Parent::operator=(static_cast<const Parent&>(copy));\
    5.28    return *this; \
    5.29  } \
    5.30 -template <typename CMap> NodeMap& operator=(const CMap& copy) { \
    5.31 -  MapImpl::operator=(copy);\
    5.32 +template <typename TT> \
    5.33 +NodeMap& operator=(const NodeMap<TT>& copy) { \
    5.34 +  Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
    5.35    return *this; \
    5.36  } \
    5.37  };
    5.38 @@ -66,21 +69,25 @@
    5.39  #define CREATE_EDGE_MAP(DynMap) \
    5.40  template <typename Value> \
    5.41  class EdgeMap : public DynMap<EdgeMapRegistry, Value> { \
    5.42 -typedef DynMap<EdgeMapRegistry, Value> MapImpl; \
    5.43  public: \
    5.44 +typedef DynMap<EdgeMapRegistry, Value> Parent; \
    5.45 +\
    5.46  EdgeMap() {} \
    5.47 -EdgeMap(const typename MapImpl::Graph& g) \
    5.48 -  : MapImpl(g, g.edge_maps) {} \
    5.49 -EdgeMap(const typename MapImpl::Graph& g, const Value& v) \
    5.50 -  : MapImpl(g, g.edge_maps, v) {} \
    5.51 -EdgeMap(const EdgeMap& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {} \
    5.52 -template <typename CMap> EdgeMap(const CMap& copy) : MapImpl(copy) {} \
    5.53 +EdgeMap(const typename Parent::Graph& g) \
    5.54 +  : Parent(g, g.edge_maps) {} \
    5.55 +EdgeMap(const typename Parent::Graph& g, const Value& v) \
    5.56 +  : Parent(g, g.edge_maps, v) {} \
    5.57 +EdgeMap(const EdgeMap& copy) : Parent(static_cast<const Parent&>(copy)) {} \
    5.58 +template <typename TT> \
    5.59 +EdgeMap(const EdgeMap<TT>& copy) \
    5.60 +  : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
    5.61  EdgeMap& operator=(const EdgeMap& copy) { \
    5.62 -  MapImpl::operator=(static_cast<const MapImpl&>(copy));\
    5.63 +  Parent::operator=(static_cast<const Parent&>(copy));\
    5.64    return *this; \
    5.65  } \
    5.66 -template <typename CMap> EdgeMap& operator=(const CMap& copy) { \
    5.67 -  MapImpl::operator=(copy);\
    5.68 +template <typename TT> \
    5.69 +EdgeMap& operator=(const EdgeMap<TT>& copy) { \
    5.70 +  Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
    5.71    return *this; \
    5.72  } \
    5.73  };
    5.74 @@ -108,101 +115,88 @@
    5.75  #define CREATE_SYM_EDGE_MAP(DynMap) \
    5.76  template <typename Value> \
    5.77  class SymEdgeMap : public SymMap<DynMap, SymEdgeMapRegistry, Value> { \
    5.78 -  typedef SymMap<DynMap, SymEdgeMapRegistry, Value> MapImpl; \
    5.79 - public: \
    5.80 +public: \
    5.81 +typedef SymMap<DynMap, SymEdgeMapRegistry, Value> Parent; \
    5.82  \
    5.83 -  SymEdgeMap() {} \
    5.84 -\
    5.85 -  SymEdgeMap(const typename MapImpl::Graph& g) \
    5.86 -    : MapImpl(g, g.sym_edge_maps) {} \
    5.87 -\
    5.88 -  SymEdgeMap(const typename MapImpl::Graph& g, const Value& v) \
    5.89 -    : MapImpl(g, g.sym_edge_maps, v) {} \
    5.90 -\
    5.91 -  SymEdgeMap(const SymEdgeMap& copy) \
    5.92 -    : MapImpl(static_cast<const MapImpl&>(copy)) {} \
    5.93 -\
    5.94 -  template <typename CMap> SymEdgeMap(const CMap& copy) : MapImpl(copy) {} \
    5.95 -  SymEdgeMap& operator=(const SymEdgeMap& copy) { \
    5.96 -    MapImpl::operator=(static_cast<const MapImpl&>(copy));\
    5.97 -    return *this; \
    5.98 -  } \
    5.99 -\
   5.100 -  template <typename CMap> SymEdgeMap& operator=(const CMap& copy) { \
   5.101 -    MapImpl::operator=(copy);\
   5.102 -    return *this; \
   5.103 -  } \
   5.104 +SymEdgeMap() {} \
   5.105 +SymEdgeMap(const typename Parent::Graph& g) \
   5.106 +  : Parent(g, g.sym_edge_maps) {} \
   5.107 +SymEdgeMap(const typename Parent::Graph& g, const Value& v) \
   5.108 +  : Parent(g, g.sym_edge_maps, v) {} \
   5.109 +SymEdgeMap(const SymEdgeMap& copy) \
   5.110 +  : Parent(static_cast<const Parent&>(copy)) {} \
   5.111 +template <typename TT> \
   5.112 +SymEdgeMap(const NodeMap<TT>& copy) \
   5.113 +  : Parent(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy)) {} \
   5.114 +SymEdgeMap& operator=(const SymEdgeMap& copy) { \
   5.115 +  Parent::operator=(static_cast<const Parent&>(copy));\
   5.116 +  return *this; \
   5.117 +} \
   5.118 +template <typename TT> \
   5.119 +SymEdgeMap& operator=(const SymEdgeMap<TT>& copy) { \
   5.120 +  Parent::operator=(static_cast<const typename SymEdgeMap<TT>::Parent&>(copy));\
   5.121 +  return *this; \
   5.122 +} \
   5.123  };
   5.124  
   5.125 -
   5.126  /** This is a macro to import an node map into a graph class.
   5.127   */
   5.128  #define IMPORT_NODE_MAP(From, from, To, to) \
   5.129  template <typename Value> \
   5.130 -class NodeMap \
   5.131 -  : public From::template NodeMap<Value> { \
   5.132 -  typedef typename From::template NodeMap<Value> MapImpl; \
   5.133 - public: \
   5.134 -   NodeMap() : MapImpl() {} \
   5.135 +class NodeMap : public From::template NodeMap<Value> { \
   5.136  \
   5.137 -   NodeMap(const To& to) \
   5.138 -     : MapImpl(static_cast<const From&>(from)) { } \
   5.139 +public: \
   5.140 +typedef typename From::template NodeMap<Value> Parent; \
   5.141  \
   5.142 -   NodeMap(const To& to, const Value& value) \
   5.143 -     : MapImpl(static_cast<const From&>(from), value) { } \
   5.144 -\
   5.145 -   NodeMap(const NodeMap& copy) \
   5.146 -     : MapImpl(static_cast<const MapImpl&>(copy)) {} \
   5.147 -\
   5.148 -   template<typename CMap> \
   5.149 -   NodeMap(const CMap& copy) \
   5.150 -     : MapImpl(copy) {} \
   5.151 -\
   5.152 -   NodeMap& operator=(const NodeMap& copy) { \
   5.153 -     MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
   5.154 -     return *this; \
   5.155 -   } \
   5.156 -\
   5.157 -   template <typename CMap> \
   5.158 -   NodeMap& operator=(const CMap& copy) { \
   5.159 -     MapImpl::operator=(copy); \
   5.160 -     return *this; \
   5.161 -   } \
   5.162 +NodeMap() : Parent() {} \
   5.163 +NodeMap(const To& to) \
   5.164 +  : Parent(static_cast<const From&>(from)) { } \
   5.165 +NodeMap(const To& to, const Value& value) \
   5.166 +  : Parent(static_cast<const From&>(from), value) { } \
   5.167 +NodeMap(const NodeMap& copy) \
   5.168 +  : Parent(static_cast<const Parent&>(copy)) {} \
   5.169 +template <typename TT> \
   5.170 +NodeMap(const NodeMap<TT>& copy) \
   5.171 +  : Parent(static_cast<const typename NodeMap<TT>::Parent&>(copy)) {} \
   5.172 +NodeMap& operator=(const NodeMap& copy) { \
   5.173 +  Parent::operator=(static_cast<const Parent&>(copy)); \
   5.174 +  return *this; \
   5.175 +} \
   5.176 +template <typename TT> \
   5.177 +NodeMap& operator=(const NodeMap<TT>& copy) { \
   5.178 +  Parent::operator=(static_cast<const typename NodeMap<TT>::Parent&>(copy));\
   5.179 +  return *this; \
   5.180 +} \
   5.181  };
   5.182  
   5.183  /** This is a macro to import an edge map into a graph class.
   5.184   */
   5.185  #define IMPORT_EDGE_MAP(From, from, To, to) \
   5.186  template <typename Value> \
   5.187 -class EdgeMap \
   5.188 -  : public From::template EdgeMap<Value> { \
   5.189 -  typedef typename From::template EdgeMap<Value> MapImpl; \
   5.190 - public: \
   5.191 -   EdgeMap() : MapImpl() {} \
   5.192 +class EdgeMap : public From::template EdgeMap<Value> { \
   5.193  \
   5.194 -   EdgeMap(const To& to) \
   5.195 -     : MapImpl(static_cast<const From&>(from)) { } \
   5.196 +public: \
   5.197 +typedef typename From::template EdgeMap<Value> Parent; \
   5.198  \
   5.199 -   EdgeMap(const To& to, const Value& value) \
   5.200 -     : MapImpl(static_cast<const From&>(from), value) { } \
   5.201 -\
   5.202 -   EdgeMap(const EdgeMap& copy) \
   5.203 -     : MapImpl(static_cast<const MapImpl&>(copy)) {} \
   5.204 -\
   5.205 -   template<typename CMap> \
   5.206 -   EdgeMap(const CMap& copy) \
   5.207 -     : MapImpl(copy) {} \
   5.208 -\
   5.209 -   EdgeMap& operator=(const EdgeMap& copy) { \
   5.210 -     MapImpl::operator=(static_cast<const MapImpl&>(copy)); \
   5.211 -     return *this; \
   5.212 -   } \
   5.213 -\
   5.214 -   template <typename CMap> \
   5.215 -   EdgeMap& operator=(const CMap& copy) { \
   5.216 -     MapImpl::operator=(copy); \
   5.217 -     return *this; \
   5.218 -   } \
   5.219 +EdgeMap() : Parent() {} \
   5.220 +EdgeMap(const To& to) \
   5.221 +  : Parent(static_cast<const From&>(from)) { } \
   5.222 +EdgeMap(const To& to, const Value& value) \
   5.223 +  : Parent(static_cast<const From&>(from), value) { } \
   5.224 +EdgeMap(const EdgeMap& copy) \
   5.225 +  : Parent(static_cast<const Parent&>(copy)) {} \
   5.226 +template <typename TT> \
   5.227 +EdgeMap(const EdgeMap<TT>& copy) \
   5.228 +  : Parent(static_cast<const typename EdgeMap<TT>::Parent&>(copy)) {} \
   5.229 +EdgeMap& operator=(const EdgeMap& copy) { \
   5.230 +  Parent::operator=(static_cast<const Parent&>(copy)); \
   5.231 +  return *this; \
   5.232 +} \
   5.233 +template <typename TT> \
   5.234 +EdgeMap& operator=(const EdgeMap<TT>& copy) { \
   5.235 +  Parent::operator=(static_cast<const typename EdgeMap<TT>::Parent&>(copy));\
   5.236 +  return *this; \
   5.237 +} \
   5.238  };
   5.239  
   5.240  #define KEEP_EDGE_MAP(From, To) \
     6.1 --- a/src/hugo/map_registry.h	Mon Sep 20 17:53:33 2004 +0000
     6.2 +++ b/src/hugo/map_registry.h	Mon Sep 20 22:57:48 2004 +0000
     6.3 @@ -70,7 +70,6 @@
     6.4        /** 
     6.5         * Assign operator.
     6.6        */	
     6.7 -
     6.8        const MapBase& operator=(const MapBase& copy) {
     6.9  	if (registry) {
    6.10  	  registry->detach(*this);
     7.1 --- a/src/hugo/smart_graph.h	Mon Sep 20 17:53:33 2004 +0000
     7.2 +++ b/src/hugo/smart_graph.h	Mon Sep 20 22:57:48 2004 +0000
     7.3 @@ -317,9 +317,6 @@
     7.4    public:
     7.5      typedef SymSmartGraph Graph;
     7.6  
     7.7 -    /// Importing maps from the base class ListGraph.
     7.8 -    KEEP_MAPS(SmartGraph, SymSmartGraph);
     7.9 -
    7.10      /// Creating symmetric map registry.
    7.11      CREATE_SYM_EDGE_MAP_REGISTRY;
    7.12      /// Creating symmetric edge map.
     8.1 --- a/src/hugo/sym_map.h	Mon Sep 20 17:53:33 2004 +0000
     8.2 +++ b/src/hugo/sym_map.h	Mon Sep 20 22:57:48 2004 +0000
     8.3 @@ -103,11 +103,6 @@
     8.4      SymMap(const SymMap& copy) 
     8.5        : MapImpl(static_cast<const MapImpl&>(copy)) {}
     8.6  
     8.7 -    /** Constructor to copy a map of an other map type.
     8.8 -     */
     8.9 -    template <typename CMap> SymMap(const CMap& copy) 
    8.10 -      : MapImpl(copy) {}
    8.11 -
    8.12      /** Assign operator to copy a map of the same map type.
    8.13       */
    8.14      SymMap& operator=(const SymMap& copy) {
    8.15 @@ -115,13 +110,6 @@
    8.16        return *this;
    8.17      }
    8.18  
    8.19 -    /** Assign operator to copy a map of an other map type.
    8.20 -     */
    8.21 -    template <typename CMap> SymMap& operator=(const CMap& copy) {
    8.22 -      MapImpl::operator=(copy);
    8.23 -      return *this;
    8.24 -    }
    8.25 -   
    8.26      /** Add a new key to the map. It called by the map registry.
    8.27       */
    8.28      void add(const KeyType& key) {
     9.1 --- a/src/hugo/vector_map.h	Mon Sep 20 17:53:33 2004 +0000
     9.2 +++ b/src/hugo/vector_map.h	Mon Sep 20 22:57:48 2004 +0000
     9.3 @@ -32,6 +32,7 @@
     9.4  	
     9.5    template <typename MapRegistry, typename Value>
     9.6    class VectorMap : public MapRegistry::MapBase {
     9.7 +    template <typename MR, typename T> friend class VectorMap;
     9.8    public:
     9.9  		
    9.10      /// The graph type of the maps. 
    9.11 @@ -82,36 +83,29 @@
    9.12      VectorMap(const Graph& g, MapRegistry& r, const Value& v) 
    9.13        : MapBase(g, r), container(KeyInfo<Graph, KeyIt>::maxId(g)+1, v) {}
    9.14  
    9.15 -    /** Constructor to copy a map of an other map type.
    9.16 +    /** Assign operator to copy a map of an other map type.
    9.17       */
    9.18 -    template <typename CMap> VectorMap(const CMap& copy) : MapBase(copy) {
    9.19 -      if (MapBase::getGraph()) {
    9.20 -	container.resize(KeyInfo<Graph, KeyIt>::maxId(*MapBase::getGraph())+1);
    9.21 -	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    9.22 -	  set(it, copy[it]);
    9.23 -	}
    9.24 +    template <typename TT>
    9.25 +    VectorMap(const VectorMap<MapRegistry, TT>& c) 
    9.26 +      : MapBase(c), container(c.container.size()) {
    9.27 +      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    9.28 +	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
    9.29 +	container[id] = c.container[id];
    9.30        }
    9.31      }
    9.32  
    9.33 -    /** Assign operator to copy a map an other map type.
    9.34 +    /** Assign operator to copy a map of an other map type.
    9.35       */
    9.36 -    template <typename CMap> VectorMap& operator=(const CMap& copy) {
    9.37 -      container.clear();
    9.38 -      this->MapBase::operator=(copy);
    9.39 -      if (MapBase::getGraph()) {
    9.40 -	container.resize(KeyInfo<Graph, KeyIt>::maxId(*MapBase::getGraph())+1);
    9.41 -	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    9.42 -	  set(it, copy[it]);
    9.43 -	}
    9.44 +    template <typename TT>
    9.45 +    VectorMap& operator=(const VectorMap<MapRegistry, TT>& c) {
    9.46 +      container.resize(c.container.size());
    9.47 +      MapBase::operator=(c);
    9.48 +      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
    9.49 +	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
    9.50 +	container[id] = c.container[id];
    9.51        }
    9.52        return *this;
    9.53      }
    9.54 -
    9.55 -    /** The destructor of the map.
    9.56 -     */
    9.57 -    virtual ~VectorMap() {
    9.58 -    }
    9.59 -		
    9.60      /**
    9.61       * The subscript operator. The map can be subscripted by the
    9.62       * actual keys of the graph. 
    10.1 --- a/src/test/graph_test.h	Mon Sep 20 17:53:33 2004 +0000
    10.2 +++ b/src/test/graph_test.h	Mon Sep 20 22:57:48 2004 +0000
    10.3 @@ -1,3 +1,4 @@
    10.4 +// -*- c++ -*-
    10.5  #ifndef HUGO_TEST_GRAPH_TEST_H
    10.6  #define HUGO_TEST_GRAPH_TEST_H
    10.7  
    10.8 @@ -9,289 +10,299 @@
    10.9  //! \brief Some utility to  test graph classes.
   10.10  namespace hugo {
   10.11  
   10.12 +  struct DummyType {
   10.13 +    int value;
   10.14 +    DummyType() {}
   10.15 +    DummyType(int p) : value(p) {}
   10.16 +    DummyType& operator=(int p) { value = p; return *this;}
   10.17 +  };
   10.18  
   10.19 -template<class Graph> void checkCompileStaticGraph(Graph &G) 
   10.20 -{
   10.21 -  typedef typename Graph::Node Node;
   10.22 -  typedef typename Graph::NodeIt NodeIt;
   10.23 -  typedef typename Graph::Edge Edge;
   10.24 -  typedef typename Graph::EdgeIt EdgeIt;
   10.25 -  typedef typename Graph::InEdgeIt InEdgeIt;
   10.26 -  typedef typename Graph::OutEdgeIt OutEdgeIt;
   10.27 +
   10.28 +  template<class Graph> void checkCompileStaticGraph(Graph &G) 
   10.29 +    {
   10.30 +      typedef typename Graph::Node Node;
   10.31 +      typedef typename Graph::NodeIt NodeIt;
   10.32 +      typedef typename Graph::Edge Edge;
   10.33 +      typedef typename Graph::EdgeIt EdgeIt;
   10.34 +      typedef typename Graph::InEdgeIt InEdgeIt;
   10.35 +      typedef typename Graph::OutEdgeIt OutEdgeIt;
   10.36    
   10.37 -  {
   10.38 -    Node i; Node j(i); Node k(INVALID);
   10.39 -    i=j;
   10.40 -    bool b; b=true;
   10.41 -    b=(i==INVALID); b=(i!=INVALID);
   10.42 -    b=(i==j); b=(i!=j); b=(i<j);
   10.43 -  }
   10.44 -  {
   10.45 -    NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
   10.46 -    i=j;
   10.47 -    j=G.first(i);
   10.48 -    j=++i;
   10.49 -    bool b; b=true;
   10.50 -    b=(i==INVALID); b=(i!=INVALID);
   10.51 -    Node n(i);
   10.52 -    n=i;
   10.53 -    b=(i==j); b=(i!=j); b=(i<j);
   10.54 -    //Node ->NodeIt conversion
   10.55 -    NodeIt ni(G,n);
   10.56 -  }
   10.57 -  {
   10.58 -    Edge i; Edge j(i); Edge k(INVALID);
   10.59 -    i=j;
   10.60 -    bool b; b=true;
   10.61 -    b=(i==INVALID); b=(i!=INVALID);
   10.62 -    b=(i==j); b=(i!=j); b=(i<j);
   10.63 -  }
   10.64 -  {
   10.65 -    EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
   10.66 -    i=j;
   10.67 -    j=G.first(i);
   10.68 -    j=++i;
   10.69 -    bool b; b=true;
   10.70 -    b=(i==INVALID); b=(i!=INVALID);
   10.71 -    Edge e(i);
   10.72 -    e=i;
   10.73 -    b=(i==j); b=(i!=j); b=(i<j);
   10.74 -    //Edge ->EdgeIt conversion
   10.75 -    EdgeIt ei(G,e);
   10.76 -  }
   10.77 -  {
   10.78 -    Node n;
   10.79 -    InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
   10.80 -    i=j;
   10.81 -    j=G.first(i,n);
   10.82 -    j=++i;
   10.83 -    bool b; b=true;
   10.84 -    b=(i==INVALID); b=(i!=INVALID);
   10.85 -    Edge e(i);
   10.86 -    e=i;
   10.87 -    b=(i==j); b=(i!=j); b=(i<j);
   10.88 -    //Edge ->InEdgeIt conversion
   10.89 -    InEdgeIt ei(G,e);
   10.90 -  }
   10.91 -  {
   10.92 -    Node n;
   10.93 -    OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
   10.94 -    i=j;
   10.95 -    j=G.first(i,n);
   10.96 -    j=++i;
   10.97 -    bool b; b=true;
   10.98 -    b=(i==INVALID); b=(i!=INVALID);
   10.99 -    Edge e(i);
  10.100 -    e=i;
  10.101 -    b=(i==j); b=(i!=j); b=(i<j);
  10.102 -    //Edge ->OutEdgeIt conversion
  10.103 -    OutEdgeIt ei(G,e);
  10.104 -  }
  10.105 -  {
  10.106 -    Node n,m;
  10.107 -    n=m=INVALID;
  10.108 -    Edge e;
  10.109 -    e=INVALID;
  10.110 -    n=G.tail(e);
  10.111 -    n=G.head(e);
  10.112 -  }
  10.113 -  // id tests
  10.114 -  { Node n; int i=G.id(n); i=i; }
  10.115 -  { Edge e; int i=G.id(e); i=i; }
  10.116 -  //NodeMap tests
  10.117 -  {
  10.118 -    Node k;
  10.119 -    typename Graph::template NodeMap<int> m(G);
  10.120 -    //Const map
  10.121 -    typename Graph::template NodeMap<int> const &cm = m;
  10.122 -    //Inicialize with default value
  10.123 -    typename Graph::template NodeMap<int> mdef(G,12);
  10.124 -    //Copy
  10.125 -    typename Graph::template NodeMap<int> mm(cm);
  10.126 -    //Copy from another type
  10.127 -    typename Graph::template NodeMap<double> dm(cm);
  10.128 -    int v;
  10.129 -    v=m[k]; m[k]=v; m.set(k,v);
  10.130 -    v=cm[k];
  10.131 +      {
  10.132 +	Node i; Node j(i); Node k(INVALID);
  10.133 +	i=j;
  10.134 +	bool b; b=true;
  10.135 +	b=(i==INVALID); b=(i!=INVALID);
  10.136 +	b=(i==j); b=(i!=j); b=(i<j);
  10.137 +      }
  10.138 +      {
  10.139 +	NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
  10.140 +	i=j;
  10.141 +	j=G.first(i);
  10.142 +	j=++i;
  10.143 +	bool b; b=true;
  10.144 +	b=(i==INVALID); b=(i!=INVALID);
  10.145 +	Node n(i);
  10.146 +	n=i;
  10.147 +	b=(i==j); b=(i!=j); b=(i<j);
  10.148 +	//Node ->NodeIt conversion
  10.149 +	NodeIt ni(G,n);
  10.150 +      }
  10.151 +      {
  10.152 +	Edge i; Edge j(i); Edge k(INVALID);
  10.153 +	i=j;
  10.154 +	bool b; b=true;
  10.155 +	b=(i==INVALID); b=(i!=INVALID);
  10.156 +	b=(i==j); b=(i!=j); b=(i<j);
  10.157 +      }
  10.158 +      {
  10.159 +	EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
  10.160 +	i=j;
  10.161 +	j=G.first(i);
  10.162 +	j=++i;
  10.163 +	bool b; b=true;
  10.164 +	b=(i==INVALID); b=(i!=INVALID);
  10.165 +	Edge e(i);
  10.166 +	e=i;
  10.167 +	b=(i==j); b=(i!=j); b=(i<j);
  10.168 +	//Edge ->EdgeIt conversion
  10.169 +	EdgeIt ei(G,e);
  10.170 +      }
  10.171 +      {
  10.172 +	Node n;
  10.173 +	InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
  10.174 +	i=j;
  10.175 +	j=G.first(i,n);
  10.176 +	j=++i;
  10.177 +	bool b; b=true;
  10.178 +	b=(i==INVALID); b=(i!=INVALID);
  10.179 +	Edge e(i);
  10.180 +	e=i;
  10.181 +	b=(i==j); b=(i!=j); b=(i<j);
  10.182 +	//Edge ->InEdgeIt conversion
  10.183 +	InEdgeIt ei(G,e);
  10.184 +      }
  10.185 +      {
  10.186 +	Node n;
  10.187 +	OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
  10.188 +	i=j;
  10.189 +	j=G.first(i,n);
  10.190 +	j=++i;
  10.191 +	bool b; b=true;
  10.192 +	b=(i==INVALID); b=(i!=INVALID);
  10.193 +	Edge e(i);
  10.194 +	e=i;
  10.195 +	b=(i==j); b=(i!=j); b=(i<j);
  10.196 +	//Edge ->OutEdgeIt conversion
  10.197 +	OutEdgeIt ei(G,e);
  10.198 +      }
  10.199 +      {
  10.200 +	Node n,m;
  10.201 +	n=m=INVALID;
  10.202 +	Edge e;
  10.203 +	e=INVALID;
  10.204 +	n=G.tail(e);
  10.205 +	n=G.head(e);
  10.206 +      }
  10.207 +      // id tests
  10.208 +      { Node n; int i=G.id(n); i=i; }
  10.209 +      { Edge e; int i=G.id(e); i=i; }
  10.210 +      //NodeMap tests
  10.211 +      {
  10.212 +	Node k;
  10.213 +	typename Graph::template NodeMap<int> m(G);
  10.214 +	//Const map
  10.215 +	typename Graph::template NodeMap<int> const &cm = m;
  10.216 +	//Inicialize with default value
  10.217 +	typename Graph::template NodeMap<int> mdef(G,12);
  10.218 +	//Copy
  10.219 +	typename Graph::template NodeMap<int> mm(cm);
  10.220 +	//Copy from another type
  10.221 +	typename Graph::template NodeMap<double> dm(cm);
  10.222 +	//Copy to more complex type
  10.223 +	typename Graph::template NodeMap<DummyType> em(cm);
  10.224 +	int v;
  10.225 +	v=m[k]; m[k]=v; m.set(k,v);
  10.226 +	v=cm[k];
  10.227      
  10.228 -    m=cm;  
  10.229 -    dm=cm; //Copy from another type
  10.230 +	m=cm;  
  10.231 +	dm=cm; //Copy from another type  
  10.232 +	em=cm; //Copy to more complex type
  10.233 +	{
  10.234 +	  //Check the typedef's
  10.235 +	  typename Graph::template NodeMap<int>::ValueType val;
  10.236 +	  val=1;
  10.237 +	  typename Graph::template NodeMap<int>::KeyType key;
  10.238 +	  key = typename Graph::NodeIt(G);
  10.239 +	}
  10.240 +      }  
  10.241 +      { //bool NodeMap
  10.242 +	Node k;
  10.243 +	typename Graph::template NodeMap<bool> m(G);
  10.244 +	typename Graph::template NodeMap<bool> const &cm = m;  //Const map
  10.245 +	//Inicialize with default value
  10.246 +	typename Graph::template NodeMap<bool> mdef(G,12);
  10.247 +	typename Graph::template NodeMap<bool> mm(cm);   //Copy
  10.248 +	typename Graph::template NodeMap<int> dm(cm); //Copy from another type
  10.249 +	bool v;
  10.250 +	v=m[k]; m[k]=v; m.set(k,v);
  10.251 +	v=cm[k];
  10.252 +    
  10.253 +	m=cm;  
  10.254 +	dm=cm; //Copy from another type
  10.255 +	m=dm; //Copy to another type
  10.256 +
  10.257 +	{
  10.258 +	  //Check the typedef's
  10.259 +	  typename Graph::template NodeMap<bool>::ValueType val;
  10.260 +	  val=true;
  10.261 +	  typename Graph::template NodeMap<bool>::KeyType key;
  10.262 +	  key= typename Graph::NodeIt(G);
  10.263 +	}
  10.264 +      }
  10.265 +      //EdgeMap tests
  10.266 +      {
  10.267 +	Edge k;
  10.268 +	typename Graph::template EdgeMap<int> m(G);
  10.269 +	typename Graph::template EdgeMap<int> const &cm = m;  //Const map
  10.270 +	//Inicialize with default value
  10.271 +	typename Graph::template EdgeMap<int> mdef(G,12);
  10.272 +	typename Graph::template EdgeMap<int> mm(cm);   //Copy
  10.273 +	typename Graph::template EdgeMap<double> dm(cm); //Copy from another type
  10.274 +	int v;
  10.275 +	v=m[k]; m[k]=v; m.set(k,v);
  10.276 +	v=cm[k];
  10.277 +    
  10.278 +	m=cm;  
  10.279 +	dm=cm; //Copy from another type
  10.280 +	{
  10.281 +	  //Check the typedef's
  10.282 +	  typename Graph::template EdgeMap<int>::ValueType val;
  10.283 +	  val=1;
  10.284 +	  typename Graph::template EdgeMap<int>::KeyType key;
  10.285 +	  key= typename Graph::EdgeIt(G);
  10.286 +	}
  10.287 +      }  
  10.288 +      { //bool EdgeMap
  10.289 +	Edge k;
  10.290 +	typename Graph::template EdgeMap<bool> m(G);
  10.291 +	typename Graph::template EdgeMap<bool> const &cm = m;  //Const map
  10.292 +	//Inicialize with default value
  10.293 +	typename Graph::template EdgeMap<bool> mdef(G,12);
  10.294 +	typename Graph::template EdgeMap<bool> mm(cm);   //Copy
  10.295 +	typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
  10.296 +	bool v;
  10.297 +	v=m[k]; m[k]=v; m.set(k,v);
  10.298 +	v=cm[k];
  10.299 +    
  10.300 +	m=cm;  
  10.301 +	dm=cm; //Copy from another type
  10.302 +	m=dm; //Copy to another type
  10.303 +	{
  10.304 +	  //Check the typedef's
  10.305 +	  typename Graph::template EdgeMap<bool>::ValueType val;
  10.306 +	  val=true;
  10.307 +	  typename Graph::template EdgeMap<bool>::KeyType key;
  10.308 +	  key= typename Graph::EdgeIt(G);
  10.309 +	}
  10.310 +      }
  10.311 +    }
  10.312 +
  10.313 +  template<class Graph> void checkCompileGraph(Graph &G) 
  10.314      {
  10.315 -      //Check the typedef's
  10.316 -      typename Graph::template NodeMap<int>::ValueType val;
  10.317 -      val=1;
  10.318 -      typename Graph::template NodeMap<int>::KeyType key;
  10.319 -      key = typename Graph::NodeIt(G);
  10.320 +      checkCompileStaticGraph(G);
  10.321 +
  10.322 +      typedef typename Graph::Node Node;
  10.323 +      typedef typename Graph::NodeIt NodeIt;
  10.324 +      typedef typename Graph::Edge Edge;
  10.325 +      typedef typename Graph::EdgeIt EdgeIt;
  10.326 +      typedef typename Graph::InEdgeIt InEdgeIt;
  10.327 +      typedef typename Graph::OutEdgeIt OutEdgeIt;
  10.328 +  
  10.329 +      Node n,m;
  10.330 +      n=G.addNode();
  10.331 +      m=G.addNode();
  10.332 +      Edge e;
  10.333 +      e=G.addEdge(n,m); 
  10.334 +  
  10.335 +      //  G.clear();
  10.336      }
  10.337 -  }  
  10.338 -  { //bool NodeMap
  10.339 -    Node k;
  10.340 -    typename Graph::template NodeMap<bool> m(G);
  10.341 -    typename Graph::template NodeMap<bool> const &cm = m;  //Const map
  10.342 -    //Inicialize with default value
  10.343 -    typename Graph::template NodeMap<bool> mdef(G,12);
  10.344 -    typename Graph::template NodeMap<bool> mm(cm);   //Copy
  10.345 -    typename Graph::template NodeMap<int> dm(cm); //Copy from another type
  10.346 -    bool v;
  10.347 -    v=m[k]; m[k]=v; m.set(k,v);
  10.348 -    v=cm[k];
  10.349 -    
  10.350 -    m=cm;  
  10.351 -    dm=cm; //Copy from another type
  10.352 -    m=dm; //Copy to another type
  10.353  
  10.354 +  template<class Graph> void checkCompileGraphEraseEdge(Graph &G) 
  10.355      {
  10.356 -      //Check the typedef's
  10.357 -      typename Graph::template NodeMap<bool>::ValueType val;
  10.358 -      val=true;
  10.359 -      typename Graph::template NodeMap<bool>::KeyType key;
  10.360 -      key= typename Graph::NodeIt(G);
  10.361 +      typename Graph::Edge e;
  10.362 +      G.erase(e);
  10.363      }
  10.364 -  }
  10.365 -  //EdgeMap tests
  10.366 -  {
  10.367 -    Edge k;
  10.368 -    typename Graph::template EdgeMap<int> m(G);
  10.369 -    typename Graph::template EdgeMap<int> const &cm = m;  //Const map
  10.370 -    //Inicialize with default value
  10.371 -    typename Graph::template EdgeMap<int> mdef(G,12);
  10.372 -    typename Graph::template EdgeMap<int> mm(cm);   //Copy
  10.373 -    typename Graph::template EdgeMap<double> dm(cm); //Copy from another type
  10.374 -    int v;
  10.375 -    v=m[k]; m[k]=v; m.set(k,v);
  10.376 -    v=cm[k];
  10.377 -    
  10.378 -    m=cm;  
  10.379 -    dm=cm; //Copy from another type
  10.380 +
  10.381 +  template<class Graph> void checkCompileGraphEraseNode(Graph &G) 
  10.382      {
  10.383 -      //Check the typedef's
  10.384 -      typename Graph::template EdgeMap<int>::ValueType val;
  10.385 -      val=1;
  10.386 -      typename Graph::template EdgeMap<int>::KeyType key;
  10.387 -      key= typename Graph::EdgeIt(G);
  10.388 +      typename Graph::Node n;
  10.389 +      G.erase(n);
  10.390      }
  10.391 -  }  
  10.392 -  { //bool EdgeMap
  10.393 -    Edge k;
  10.394 -    typename Graph::template EdgeMap<bool> m(G);
  10.395 -    typename Graph::template EdgeMap<bool> const &cm = m;  //Const map
  10.396 -    //Inicialize with default value
  10.397 -    typename Graph::template EdgeMap<bool> mdef(G,12);
  10.398 -    typename Graph::template EdgeMap<bool> mm(cm);   //Copy
  10.399 -    typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
  10.400 -    bool v;
  10.401 -    v=m[k]; m[k]=v; m.set(k,v);
  10.402 -    v=cm[k];
  10.403 -    
  10.404 -    m=cm;  
  10.405 -    dm=cm; //Copy from another type
  10.406 -    m=dm; //Copy to another type
  10.407 +
  10.408 +  template<class Graph> void checkCompileErasableGraph(Graph &G) 
  10.409      {
  10.410 -      //Check the typedef's
  10.411 -      typename Graph::template EdgeMap<bool>::ValueType val;
  10.412 -      val=true;
  10.413 -      typename Graph::template EdgeMap<bool>::KeyType key;
  10.414 -      key= typename Graph::EdgeIt(G);
  10.415 +      checkCompileGraph(G);
  10.416 +      checkCompileGraphEraseNode(G);
  10.417 +      checkCompileGraphEraseEdge(G);
  10.418      }
  10.419 -  }
  10.420 -}
  10.421  
  10.422 -template<class Graph> void checkCompileGraph(Graph &G) 
  10.423 -{
  10.424 -  checkCompileStaticGraph(G);
  10.425 +  template<class Graph> void checkCompileGraphFindEdge(Graph &G) 
  10.426 +    {
  10.427 +      typedef typename Graph::NodeIt Node;
  10.428 +      typedef typename Graph::NodeIt NodeIt;
  10.429  
  10.430 -  typedef typename Graph::Node Node;
  10.431 -  typedef typename Graph::NodeIt NodeIt;
  10.432 -  typedef typename Graph::Edge Edge;
  10.433 -  typedef typename Graph::EdgeIt EdgeIt;
  10.434 -  typedef typename Graph::InEdgeIt InEdgeIt;
  10.435 -  typedef typename Graph::OutEdgeIt OutEdgeIt;
  10.436 -  
  10.437 -  Node n,m;
  10.438 -  n=G.addNode();
  10.439 -  m=G.addNode();
  10.440 -  Edge e;
  10.441 -  e=G.addEdge(n,m); 
  10.442 -  
  10.443 -  //  G.clear();
  10.444 -}
  10.445 +      G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
  10.446 +      G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));  
  10.447 +    }
  10.448  
  10.449 -template<class Graph> void checkCompileGraphEraseEdge(Graph &G) 
  10.450 -{
  10.451 -  typename Graph::Edge e;
  10.452 -  G.erase(e);
  10.453 -}
  10.454 +  template<class Graph> void checkGraphNodeList(Graph &G, int nn)
  10.455 +    {
  10.456 +      typename Graph::NodeIt n(G);
  10.457 +      for(int i=0;i<nn;i++) {
  10.458 +	check(n!=INVALID,"Wrong Node list linking.");
  10.459 +	++n;
  10.460 +      }
  10.461 +      check(n==INVALID,"Wrong Node list linking.");
  10.462 +    }
  10.463  
  10.464 -template<class Graph> void checkCompileGraphEraseNode(Graph &G) 
  10.465 -{
  10.466 -  typename Graph::Node n;
  10.467 -  G.erase(n);
  10.468 -}
  10.469 +  template<class Graph> void checkGraphEdgeList(Graph &G, int nn)
  10.470 +    {
  10.471 +      typedef typename Graph::EdgeIt EdgeIt;
  10.472  
  10.473 -template<class Graph> void checkCompileErasableGraph(Graph &G) 
  10.474 -{
  10.475 -  checkCompileGraph(G);
  10.476 -  checkCompileGraphEraseNode(G);
  10.477 -  checkCompileGraphEraseEdge(G);
  10.478 -}
  10.479 +      EdgeIt e(G);
  10.480 +      for(int i=0;i<nn;i++) {
  10.481 +	check(e!=INVALID,"Wrong Edge list linking.");
  10.482 +	++e;
  10.483 +      }
  10.484 +      check(e==INVALID,"Wrong Edge list linking.");
  10.485 +    }
  10.486  
  10.487 -template<class Graph> void checkCompileGraphFindEdge(Graph &G) 
  10.488 -{
  10.489 -  typedef typename Graph::NodeIt Node;
  10.490 -  typedef typename Graph::NodeIt NodeIt;
  10.491 +  template<class Graph> void checkGraphOutEdgeList(Graph &G,
  10.492 +						   typename Graph::Node n,
  10.493 +						   int nn)
  10.494 +    {
  10.495 +      typename Graph::OutEdgeIt e(G,n);
  10.496 +      for(int i=0;i<nn;i++) {
  10.497 +	check(e!=INVALID,"Wrong OutEdge list linking.");
  10.498 +	++e;
  10.499 +      }
  10.500 +      check(e==INVALID,"Wrong OutEdge list linking.");
  10.501 +    }
  10.502  
  10.503 -  G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
  10.504 -  G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));  
  10.505 -}
  10.506 +  template<class Graph> void checkGraphInEdgeList(Graph &G,
  10.507 +						  typename Graph::Node n,
  10.508 +						  int nn)
  10.509 +    {
  10.510 +      typename Graph::InEdgeIt e(G,n);
  10.511 +      for(int i=0;i<nn;i++) {
  10.512 +	check(e!=INVALID,"Wrong InEdge list linking.");
  10.513 +	++e;
  10.514 +      }
  10.515 +      check(e==INVALID,"Wrong InEdge list linking.");
  10.516 +    }
  10.517  
  10.518 -template<class Graph> void checkGraphNodeList(Graph &G, int nn)
  10.519 -{
  10.520 -  typename Graph::NodeIt n(G);
  10.521 -  for(int i=0;i<nn;i++) {
  10.522 -    check(n!=INVALID,"Wrong Node list linking.");
  10.523 -    ++n;
  10.524 -  }
  10.525 -  check(n==INVALID,"Wrong Node list linking.");
  10.526 -}
  10.527 -
  10.528 -template<class Graph> void checkGraphEdgeList(Graph &G, int nn)
  10.529 -{
  10.530 -  typedef typename Graph::EdgeIt EdgeIt;
  10.531 -
  10.532 -  EdgeIt e(G);
  10.533 -  for(int i=0;i<nn;i++) {
  10.534 -    check(e!=INVALID,"Wrong Edge list linking.");
  10.535 -    ++e;
  10.536 -  }
  10.537 -  check(e==INVALID,"Wrong Edge list linking.");
  10.538 -}
  10.539 -
  10.540 -template<class Graph> void checkGraphOutEdgeList(Graph &G,
  10.541 -						 typename Graph::Node n,
  10.542 -						 int nn)
  10.543 -{
  10.544 -  typename Graph::OutEdgeIt e(G,n);
  10.545 -  for(int i=0;i<nn;i++) {
  10.546 -    check(e!=INVALID,"Wrong OutEdge list linking.");
  10.547 -    ++e;
  10.548 -  }
  10.549 -  check(e==INVALID,"Wrong OutEdge list linking.");
  10.550 -}
  10.551 -
  10.552 -template<class Graph> void checkGraphInEdgeList(Graph &G,
  10.553 -						typename Graph::Node n,
  10.554 -						int nn)
  10.555 -{
  10.556 -  typename Graph::InEdgeIt e(G,n);
  10.557 -  for(int i=0;i<nn;i++) {
  10.558 -    check(e!=INVALID,"Wrong InEdge list linking.");
  10.559 -    ++e;
  10.560 -  }
  10.561 -  check(e==INVALID,"Wrong InEdge list linking.");
  10.562 -}
  10.563 -
  10.564 -///\file
  10.565 -///\todo Check head(), tail() as well;
  10.566 +  ///\file
  10.567 +  ///\todo Check head(), tail() as well;
  10.568  
  10.569    
  10.570  } //namespace hugo
    11.1 --- a/src/test/graph_wrapper_test.cc	Mon Sep 20 17:53:33 2004 +0000
    11.2 +++ b/src/test/graph_wrapper_test.cc	Mon Sep 20 22:57:48 2004 +0000
    11.3 @@ -18,16 +18,51 @@
    11.4  using namespace hugo;
    11.5  
    11.6  
    11.7 -//Compile SmartGraph
    11.8  typedef SmartGraph Graph;
    11.9 +
   11.10 +//Compile GraphWrapper
   11.11  typedef GraphWrapper<Graph> GW;
   11.12  template void checkCompileStaticGraph<GW>(GW &);
   11.13 -//template void checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
   11.14  
   11.15 -//Compile SymSmartGraph
   11.16 +//Compile RevGraphWrapper
   11.17  typedef RevGraphWrapper<Graph> RevGW;
   11.18  template void checkCompileStaticGraph<RevGW>(RevGW &);
   11.19 -//template void checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
   11.20 +
   11.21 +//Compile SubGraphWrapper
   11.22 +typedef SubGraphWrapper<Graph, Graph::NodeMap<bool>, 
   11.23 +			Graph::EdgeMap<bool> > SubGW;
   11.24 +template void checkCompileStaticGraph<SubGW>(SubGW &);
   11.25 +
   11.26 +//Compile UndirGraphWrapper
   11.27 +/// \bug UndirGraphWrapper cannot pass the StaticGraph test
   11.28 +//typedef UndirGraphWrapper<Graph> UndirGW;
   11.29 +//template void checkCompileStaticGraph<UndirGW>(UndirGW &);
   11.30 +
   11.31 +//Compile UndirGraph
   11.32 +//typedef UndirGraph<Graph> UndirG;
   11.33 +//template void checkCompileStaticGraph<UndirG>(UndirG &);
   11.34 +
   11.35 +//typedef SubBidirGraphWrapper<Graph, Graph::EdgeMap<bool>, 
   11.36 +/// \bug SubBidirGraphWrapper cannot pass the StaticGraph test
   11.37 +//			     Graph::EdgeMap<bool> > SubBDGW;
   11.38 +//template void checkCompileStaticGraph<SubBDGW>(SubBDGW &);
   11.39 +
   11.40 +//Compile BidirGraphWrapper
   11.41 +//typedef BidirGraphWrapper<Graph> BidirGW;
   11.42 +//template void checkCompileStaticGraph<BidirGW>(BidirGW &);
   11.43 +
   11.44 +//Compile BidirGraph
   11.45 +//typedef BidirGraph<Graph> BidirG;
   11.46 +//template void checkCompileStaticGraph<BidirG>(BidirG &);
   11.47 +
   11.48 +//Compile ResGraphWrapper
   11.49 +//typedef ResGraphWrapper<Graph, int, Graph::EdgeMap<int>, 
   11.50 +//			Graph::EdgeMap<int> > ResGW;
   11.51 +//template void checkCompileStaticGraph<ResGW>(ResGW &);
   11.52 +
   11.53 +//Compile ErasingFirstGraphWrapper
   11.54 +typedef ErasingFirstGraphWrapper<Graph, Graph::NodeMap<Graph::Edge> > ErasingFirstGW;
   11.55 +template void checkCompileStaticGraph<ErasingFirstGW>(ErasingFirstGW &);
   11.56  
   11.57  
   11.58  int main()