# HG changeset patch # User deba # Date 1141208245 0 # Node ID 15fb7a4ea6be613fd42b19c643d1329692666f52 # Parent d276e88aa48afe37d3ad34ccbb1cb4787eb45e23 Some classes assumed that the GraphMaps should be inherited from an ObserverBase. These classes parents replaced with DefaultMap which cause that the graph maps should not be inherited from the ObserverBase. diff -r d276e88aa48a -r 15fb7a4ea6be lemon/edge_set.h --- a/lemon/edge_set.h Wed Mar 01 10:04:47 2006 +0000 +++ b/lemon/edge_set.h Wed Mar 01 10:17:25 2006 +0000 @@ -20,6 +20,7 @@ #define LEMON_EDGE_SET_H +#include #include /// \ingroup graphs @@ -45,7 +46,7 @@ NodeT() : first_out(-1), first_in(-1) {} }; - typedef typename Graph::template NodeMap NodesImplBase; + typedef DefaultMap NodesImplBase; NodesImplBase* nodes; @@ -196,6 +197,12 @@ Node source(const Edge& edge) const { return edges[edge.id].source;} Node target(const Edge& edge) const { return edges[edge.id].target;} + typedef typename ItemSetTraits::ItemNotifier NodeNotifier; + + NodeNotifier& getNotifier(Node) const { + return graph->getNotifier(Node()); + } + template class NodeMap : public Graph::template NodeMap<_Value> { public: @@ -404,7 +411,7 @@ NodeT() : first_out(-1), first_in(-1) {} }; - typedef typename Graph::template NodeMap NodesImplBase; + typedef DefaultMap NodesImplBase; NodesImplBase* nodes; @@ -505,6 +512,12 @@ Node source(const Edge& edge) const { return edges[edge.id].source;} Node target(const Edge& edge) const { return edges[edge.id].target;} + typedef typename ItemSetTraits::ItemNotifier NodeNotifier; + + NodeNotifier& getNotifier(Node) const { + return graph->getNotifier(Node()); + } + template class NodeMap : public Graph::template NodeMap<_Value> { public: diff -r d276e88aa48a -r 15fb7a4ea6be lemon/graph_utils.h --- a/lemon/graph_utils.h Wed Mar 01 10:04:47 2006 +0000 +++ b/lemon/graph_utils.h Wed Mar 01 10:17:25 2006 +0000 @@ -28,7 +28,9 @@ #include #include #include + #include +#include ///\ingroup gutils ///\file @@ -900,8 +902,8 @@ #ifndef DOXYGEN /// \param _Map A ReadWriteMap mapping from the item type to integer. template < - typename _Graph, typename _Item, typename _Value, typename _Map - = typename ItemSetTraits<_Graph, _Item>::template Map<_Value>::Parent + typename _Graph, typename _Item, typename _Value, + typename _Map = DefaultMap<_Graph, _Item, _Value> > #else template @@ -1105,8 +1107,8 @@ #ifndef DOXYGEN /// \param _Map A ReadWriteMap mapping from the item type to integer. template < - typename _Graph, typename _Item, typename _Map - = typename ItemSetTraits<_Graph, _Item>::template Map::Parent + typename _Graph, typename _Item, + typename _Map = DefaultMap<_Graph, _Item, int> > #else template @@ -1505,14 +1507,11 @@ private: - class AutoNodeMap : public Graph::template NodeMap { + class AutoNodeMap : public DefaultMap<_Graph, Key, int> { public: - typedef typename Graph::template NodeMap Parent; + typedef DefaultMap<_Graph, Key, int> Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; - AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} virtual void add(const Key& key) { @@ -1622,14 +1621,11 @@ private: - class AutoNodeMap : public Graph::template NodeMap { + class AutoNodeMap : public DefaultMap<_Graph, Key, int> { public: - typedef typename Graph::template NodeMap Parent; + typedef DefaultMap<_Graph, Key, int> Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; - AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} virtual void add(const Key& key) { @@ -1663,7 +1659,7 @@ ObserverBase::detach(); } - /// Gives back the in-degree of a Node. + /// Gives back the out-degree of a Node. int operator[](const Key& key) const { return deg[key]; } diff -r d276e88aa48a -r 15fb7a4ea6be lemon/iterable_maps.h --- a/lemon/iterable_maps.h Wed Mar 01 10:04:47 2006 +0000 +++ b/lemon/iterable_maps.h Wed Mar 01 10:17:25 2006 +0000 @@ -19,6 +19,8 @@ #include #include +#include + #include #include @@ -47,14 +49,12 @@ /// \param _Graph The graph type. /// \param _Item One of the graph's item type, the key of the map. template - class IterableBoolMap - : protected ItemSetTraits<_Graph, _Item>::template Map::Parent { + class IterableBoolMap : protected DefaultMap<_Graph, _Item, int> { private: typedef _Graph Graph; typedef typename ItemSetTraits::ItemIt KeyIt; - typedef typename ItemSetTraits - ::template Map::Parent Parent; + typedef DefaultMap<_Graph, _Item, int> Parent; std::vector<_Item> array; int sep; @@ -399,12 +399,13 @@ /// \param _Graph The graph type. /// \param _Item One of the graph's item type, the key of the map. template - class IterableIntMap : protected ItemSetTraits<_Graph, _Item> - ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >::Parent { + class IterableIntMap + : protected DefaultMap<_Graph, _Item, _iterable_maps_bits:: + IterableIntMapNode<_Item> > { public: - typedef typename ItemSetTraits<_Graph, _Item> - ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> > - ::Parent Parent; + typedef DefaultMap<_Graph, _Item, _iterable_maps_bits:: + IterableIntMapNode<_Item> > + Parent; /// The key type typedef _Item Key; @@ -687,13 +688,12 @@ /// \param _Item One of the graph's item type, the key of the map. /// \param _Value Any comparable value type. template - class IterableValueMap : protected ItemSetTraits<_Graph, _Item> - ::template Map<_iterable_maps_bits::IterableValueMapNode<_Item, _Value> > - ::Parent { + class IterableValueMap + : protected DefaultMap<_Graph, _Item, _iterable_maps_bits:: + IterableValueMapNode<_Item, _Value> > { public: - typedef typename ItemSetTraits<_Graph, _Item> - ::template Map<_iterable_maps_bits::IterableValueMapNode<_Item, _Value> > - ::Parent Parent; + typedef DefaultMap<_Graph, _Item, _iterable_maps_bits:: + IterableValueMapNode<_Item, _Value> > Parent; /// The key type typedef _Item Key; @@ -702,19 +702,25 @@ /// The graph type typedef _Graph Graph; + protected: + + typedef typename ItemSetTraits<_Graph, Key>::ItemIt KeyIt; + + public: + /// \brief Constructor of the Map with a given value. /// /// Constructor of the Map with a given value. explicit IterableValueMap(const Graph& graph, const Value& value = Value()) - : Parent(graph, _iterable_maps_bits::IterableValueMapNode<_Item, - _Value>(value)) { - for (typename Parent::ItemIt it(*this); it != INVALID; ++it) { + : Parent(graph, _iterable_maps_bits:: + IterableValueMapNode<_Item, _Value>(value)) { + for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) { lace(it); } } - private: + protected: void unlace(const Key& key) { typename Parent::Value& node = Parent::operator[](key); @@ -871,6 +877,18 @@ protected: + virtual void add(const Key& key) { + Parent::add(key); + unlace(key); + } + + virtual void add(const std::vector& keys) { + Parent::add(keys); + for (int i = 0; i < (int)keys.size(); ++i) { + lace(keys[i]); + } + } + virtual void erase(const Key& key) { unlace(key); Parent::erase(key); @@ -883,6 +901,13 @@ Parent::erase(keys); } + virtual void build() { + Parent::build(); + for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) { + lace(it); + } + } + virtual void clear() { first.clear(); Parent::clear(); diff -r d276e88aa48a -r 15fb7a4ea6be lemon/sub_graph.h --- a/lemon/sub_graph.h Wed Mar 01 10:04:47 2006 +0000 +++ b/lemon/sub_graph.h Wed Mar 01 10:17:25 2006 +0000 @@ -20,6 +20,8 @@ #define LEMON_SUB_GRAPH_H #include +#include +#include namespace lemon { @@ -242,10 +244,10 @@ Node prev, next; Edge firstIn, firstOut; }; - class NodesImpl : public Graph::template NodeMap { + class NodesImpl : public DefaultMap { friend class SubGraphBase; public: - typedef typename Graph::template NodeMap Parent; + typedef DefaultMap Parent; NodesImpl(SubGraph& _adaptor, const Graph& _graph) : Parent(_graph), adaptor(_adaptor) {} @@ -305,10 +307,10 @@ Edge prevOut, nextOut; Edge prevIn, nextIn; }; - class EdgesImpl : public Graph::template EdgeMap { + class EdgesImpl : public DefaultMap { friend class SubGraphBase; public: - typedef typename Graph::template EdgeMap Parent; + typedef DefaultMap Parent; EdgesImpl(SubGraph& _adaptor, const Graph& _graph) : Parent(_graph), adaptor(_adaptor) {} @@ -560,10 +562,10 @@ struct NodeT { Edge firstIn, firstOut; }; - class NodesImpl : public Graph::template NodeMap { + class NodesImpl : public DefaultMap { friend class EdgeSubGraphBase; public: - typedef typename Graph::template NodeMap Parent; + typedef DefaultMap Parent; NodesImpl(SubGraph& _adaptor, const Graph& _graph) : Parent(_graph), adaptor(_adaptor) {} @@ -603,10 +605,10 @@ Edge prevOut, nextOut; Edge prevIn, nextIn; }; - class EdgesImpl : public Graph::template EdgeMap { + class EdgesImpl : public DefaultMap { friend class EdgeSubGraphBase; public: - typedef typename Graph::template EdgeMap Parent; + typedef DefaultMap Parent; EdgesImpl(SubGraph& _adaptor, const Graph& _graph) : Parent(_graph), adaptor(_adaptor) {} diff -r d276e88aa48a -r 15fb7a4ea6be test/edge_set_test.cc --- a/test/edge_set_test.cc Wed Mar 01 10:04:47 2006 +0000 +++ b/test/edge_set_test.cc Wed Mar 01 10:17:25 2006 +0000 @@ -17,7 +17,7 @@ using namespace lemon; using namespace lemon::concept; -typedef StaticGraph Graph; +typedef SmartGraph Graph; int main() { { // checking edge_sets