[Lemon-commits] [lemon_svn] deba: r2592 - in hugo/trunk: lemon test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:53:45 CET 2006


Author: deba
Date: Wed Mar  1 11:17:25 2006
New Revision: 2592

Modified:
   hugo/trunk/lemon/edge_set.h
   hugo/trunk/lemon/graph_utils.h
   hugo/trunk/lemon/iterable_maps.h
   hugo/trunk/lemon/sub_graph.h
   hugo/trunk/test/edge_set_test.cc

Log:
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.




Modified: hugo/trunk/lemon/edge_set.h
==============================================================================
--- hugo/trunk/lemon/edge_set.h	(original)
+++ hugo/trunk/lemon/edge_set.h	Wed Mar  1 11:17:25 2006
@@ -20,6 +20,7 @@
 #define LEMON_EDGE_SET_H
 
 
+#include <lemon/bits/default_map.h>
 #include <lemon/bits/edge_set_extender.h>
 
 /// \ingroup graphs
@@ -45,7 +46,7 @@
       NodeT() : first_out(-1), first_in(-1) {}
     };
 
-    typedef typename Graph::template NodeMap<NodeT> NodesImplBase;
+    typedef DefaultMap<Graph, Node, NodeT> 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<Graph, Node>::ItemNotifier NodeNotifier;
+
+    NodeNotifier& getNotifier(Node) const {
+      return graph->getNotifier(Node());
+    } 
+
     template <typename _Value>
     class NodeMap : public Graph::template NodeMap<_Value> {
     public:
@@ -404,7 +411,7 @@
       NodeT() : first_out(-1), first_in(-1) {}
     };
 
-    typedef typename Graph::template NodeMap<NodeT> NodesImplBase;
+    typedef DefaultMap<Graph, Node, NodeT> 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<Graph, Node>::ItemNotifier NodeNotifier;
+
+    NodeNotifier& getNotifier(Node) const {
+      return graph->getNotifier(Node());
+    } 
+
     template <typename _Value>
     class NodeMap : public Graph::template NodeMap<_Value> {
     public:

Modified: hugo/trunk/lemon/graph_utils.h
==============================================================================
--- hugo/trunk/lemon/graph_utils.h	(original)
+++ hugo/trunk/lemon/graph_utils.h	Wed Mar  1 11:17:25 2006
@@ -28,7 +28,9 @@
 #include <lemon/utility.h>
 #include <lemon/maps.h>
 #include <lemon/traits.h>
+
 #include <lemon/bits/alteration_notifier.h>
+#include <lemon/bits/default_map.h>
 
 ///\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 <typename _Graph, typename _Item, typename _Value>
@@ -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<int>::Parent 
+    typename _Graph, typename _Item,
+    typename _Map = DefaultMap<_Graph, _Item, int>
   >
 #else
   template <typename _Graph, typename _Item>
@@ -1505,14 +1507,11 @@
 
   private:
 
-    class AutoNodeMap : public Graph::template NodeMap<int> {
+    class AutoNodeMap : public DefaultMap<_Graph, Key, int> {
     public:
 
-      typedef typename Graph::template NodeMap<int> 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<int> {
+    class AutoNodeMap : public DefaultMap<_Graph, Key, int> {
     public:
 
-      typedef typename Graph::template NodeMap<int> 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];
     }

Modified: hugo/trunk/lemon/iterable_maps.h
==============================================================================
--- hugo/trunk/lemon/iterable_maps.h	(original)
+++ hugo/trunk/lemon/iterable_maps.h	Wed Mar  1 11:17:25 2006
@@ -19,6 +19,8 @@
 #include <lemon/traits.h>
 #include <lemon/invalid.h>
 
+#include <lemon/bits/default_map.h>
+
 #include <vector>
 #include <map>
 
@@ -47,14 +49,12 @@
   /// \param _Graph The graph type.
   /// \param _Item One of the graph's item type, the key of the map.
   template <typename _Graph, typename _Item>
-  class IterableBoolMap 
-    : protected ItemSetTraits<_Graph, _Item>::template Map<int>::Parent {
+  class IterableBoolMap : protected DefaultMap<_Graph, _Item, int> {
   private:
     typedef _Graph Graph;
     
     typedef typename ItemSetTraits<Graph, _Item>::ItemIt KeyIt;
-    typedef typename ItemSetTraits<Graph, _Item>
-    ::template Map<int>::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 <typename _Graph, typename _Item>
-  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 <typename _Graph, typename _Item, typename _Value>
-  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<Key>& 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();

Modified: hugo/trunk/lemon/sub_graph.h
==============================================================================
--- hugo/trunk/lemon/sub_graph.h	(original)
+++ hugo/trunk/lemon/sub_graph.h	Wed Mar  1 11:17:25 2006
@@ -20,6 +20,8 @@
 #define LEMON_SUB_GRAPH_H
 
 #include <lemon/graph_adaptor.h>
+#include <lemon/bits/graph_adaptor_extender.h>
+#include <lemon/bits/default_map.h>
 
 namespace lemon {
 
@@ -242,10 +244,10 @@
       Node prev, next;
       Edge firstIn, firstOut;
     };
-    class NodesImpl : public Graph::template NodeMap<NodeT> {
+    class NodesImpl : public DefaultMap<Graph, Node, NodeT> {
       friend class SubGraphBase;
     public:
-      typedef typename Graph::template NodeMap<NodeT> Parent;
+      typedef DefaultMap<Graph, Node, NodeT> 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<EdgeT> {
+    class EdgesImpl : public DefaultMap<Graph, Edge, EdgeT> {
       friend class SubGraphBase;
     public:
-      typedef typename Graph::template EdgeMap<EdgeT> Parent;
+      typedef DefaultMap<Graph, Edge, EdgeT> 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<NodeT> {
+    class NodesImpl : public DefaultMap<Graph, Node, NodeT> {
       friend class EdgeSubGraphBase;
     public:
-      typedef typename Graph::template NodeMap<NodeT> Parent;
+      typedef DefaultMap<Graph, Node, NodeT> 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<EdgeT> {
+    class EdgesImpl : public DefaultMap<Graph, Edge, EdgeT> {
       friend class EdgeSubGraphBase;
     public:
-      typedef typename Graph::template EdgeMap<EdgeT> Parent;
+      typedef DefaultMap<Graph, Edge, EdgeT> Parent;
 
       EdgesImpl(SubGraph& _adaptor, const Graph& _graph) 
 	: Parent(_graph), adaptor(_adaptor) {}

Modified: hugo/trunk/test/edge_set_test.cc
==============================================================================
--- hugo/trunk/test/edge_set_test.cc	(original)
+++ hugo/trunk/test/edge_set_test.cc	Wed Mar  1 11:17:25 2006
@@ -17,7 +17,7 @@
 using namespace lemon;
 using namespace lemon::concept;
 
-typedef StaticGraph Graph;
+typedef SmartGraph Graph;
 
 int main() {
   { // checking edge_sets



More information about the Lemon-commits mailing list