Removing signal/commit Change from alteration notifier
authordeba
Mon, 17 Oct 2005 10:28:48 +0000
changeset 172906f939455cb1
parent 1728 eb8bb91ba9e2
child 1730 fffa6456548a
Removing signal/commit Change from alteration notifier

It makes slower the change Target/Source functions
and used only by the In/Out DegMap
lemon/bits/alteration_notifier.h
lemon/graph_utils.h
lemon/list_graph.h
lemon/smart_graph.h
test/graph_utils_test.cc
     1.1 --- a/lemon/bits/alteration_notifier.h	Fri Oct 14 11:03:40 2005 +0000
     1.2 +++ b/lemon/bits/alteration_notifier.h	Mon Oct 17 10:28:48 2005 +0000
     1.3 @@ -172,22 +172,6 @@
     1.4  	}
     1.5        }
     1.6  
     1.7 -      /// \brief Signal a property change on the given item.
     1.8 -      ///
     1.9 -      /// Signal a property change on the given item. It should
    1.10 -      /// be used always with the commitChange() function.
    1.11 -      /// This function is called always the property change.
    1.12 -      /// The commitChange() is called always after the change.
    1.13 -      virtual void signalChange(const Item&) {}
    1.14 -
    1.15 -      /// \brief Commit the property change on the given item.
    1.16 -      ///
    1.17 -      /// Commit the property change on the given item. It should
    1.18 -      /// be used always with the signalChange() function.
    1.19 -      /// This function is called always the property change.
    1.20 -      /// The commitChange() is called always after the change.
    1.21 -      virtual void commitChange(const Item&) {}
    1.22 -
    1.23        /// \brief The member function to notificate the observer about the
    1.24        /// container is built.
    1.25        ///
    1.26 @@ -324,32 +308,6 @@
    1.27  	(*it)->erase(items);
    1.28        }
    1.29      }
    1.30 -    
    1.31 -    /// \brief Signal a property change on the given item.
    1.32 -    ///
    1.33 -    /// Signal a property change on the given item. It should
    1.34 -    /// be used always with the commitChange() function.
    1.35 -    /// This function is called always the property change.
    1.36 -    /// The commitChange() is called always after the change.
    1.37 -    void signalChange(const Item& item) {
    1.38 -      typename Container::iterator it;
    1.39 -      for (it = container.begin(); it != container.end(); ++it) {
    1.40 -	(*it)->signalChange(item);
    1.41 -      }
    1.42 -    }
    1.43 -    
    1.44 -    /// \brief Commit the property change on the given item.
    1.45 -    ///
    1.46 -    /// Commit the property change on the given item. It should
    1.47 -    /// be used always with the signalChange() function.
    1.48 -    /// This function is called always the property change.
    1.49 -    /// The commitChange() is called always after the change.
    1.50 -    void commitChange(const Item& item) {
    1.51 -      typename Container::iterator it;
    1.52 -      for (it = container.begin(); it != container.end(); ++it) {
    1.53 -	(*it)->commitChange(item);
    1.54 -      }
    1.55 -    }
    1.56  
    1.57      /// \brief Notifies all the registered observers about the container is 
    1.58      /// built.
     2.1 --- a/lemon/graph_utils.h	Fri Oct 14 11:03:40 2005 +0000
     2.2 +++ b/lemon/graph_utils.h	Mon Oct 17 10:28:48 2005 +0000
     2.3 @@ -1325,6 +1325,14 @@
     2.4    /// in constant time. On the other hand, the values are updated automatically
     2.5    /// whenever the graph changes.
     2.6    ///
     2.7 +  /// \warning Besides addNode() and addEdge(), a graph structure may provide
     2.8 +  /// alternative ways to mogify the graph. The correct behavior of InDegMap
     2.9 +  /// is not guarantied if these additional featureas are used. For example
    2.10 +  /// the funstions \ref ListGraph::changeSource() "changeSource()",
    2.11 +  /// \ref ListGraph::changeTarget() "changeTarget()" and
    2.12 +  /// \ref ListGraph::reverseEdge() "reverseEdge()"
    2.13 +  /// of \ref ListGraph will \e not update the degree values correctly.
    2.14 +  ///
    2.15    /// \sa OutDegMap
    2.16  
    2.17    template <typename _Graph>
    2.18 @@ -1423,6 +1431,14 @@
    2.19    /// in constant time. On the other hand, the values are updated automatically
    2.20    /// whenever the graph changes.
    2.21    ///
    2.22 +  /// \warning Besides addNode() and addEdge(), a graph structure may provide
    2.23 +  /// alternative ways to mogify the graph. The correct behavior of OutDegMap
    2.24 +  /// is not guarantied if these additional featureas are used. For example
    2.25 +  /// the funstions \ref ListGraph::changeSource() "changeSource()",
    2.26 +  /// \ref ListGraph::changeTarget() "changeTarget()" and
    2.27 +  /// \ref ListGraph::reverseEdge() "reverseEdge()"
    2.28 +  /// of \ref ListGraph will \e not update the degree values correctly.
    2.29 +  ///
    2.30    /// \sa InDegMap
    2.31  
    2.32    template <typename _Graph>
     3.1 --- a/lemon/list_graph.h	Fri Oct 14 11:03:40 2005 +0000
     3.2 +++ b/lemon/list_graph.h	Mon Oct 17 10:28:48 2005 +0000
     3.3 @@ -338,9 +338,7 @@
     3.4      ///referencing the changed edge remain
     3.5      ///valid. However <tt>InEdge</tt>'s are invalidated.
     3.6      void changeTarget(Edge e, Node n) { 
     3.7 -      getNotifier(Edge()).signalChange(e); 
     3.8        _changeTarget(e,n); 
     3.9 -      getNotifier(Edge()).commitChange(e); 
    3.10      }
    3.11      /// Changes the source of \c e to \c n
    3.12  
    3.13 @@ -350,9 +348,7 @@
    3.14      ///referencing the changed edge remain
    3.15      ///valid. However <tt>OutEdge</tt>'s are invalidated.
    3.16      void changeSource(Edge e, Node n) { 
    3.17 -      getNotifier(Edge()).signalChange(e); 
    3.18        _changeSource(e,n);
    3.19 -      getNotifier(Edge()).commitChange(e); 
    3.20      }
    3.21  
    3.22      /// Invert the direction of an edge.
    3.23 @@ -362,10 +358,8 @@
    3.24      ///valid. However <tt>OutEdge</tt>'s  and <tt>InEdge</tt>'s are invalidated.
    3.25      void reverseEdge(Edge e) {
    3.26        Node t=target(e);
    3.27 -      getNotifier(Edge()).signalChange(e); 
    3.28        _changeTarget(e,source(e));
    3.29        _changeSource(e,t);
    3.30 -      getNotifier(Edge()).commitChange(e); 
    3.31      }
    3.32  
    3.33      ///Using this it possible to avoid the superfluous memory allocation.
    3.34 @@ -593,13 +587,7 @@
    3.35      /// referencing the changed edge remain
    3.36      /// valid. However <tt>InEdge</tt>'s are invalidated.
    3.37      void changeTarget(UndirEdge e, Node n) { 
    3.38 -      getNotifier(UndirEdge()).signalChange(e); 
    3.39 -      getNotifier(Edge()).signalChange(direct(e, true)); 
    3.40 -      getNotifier(Edge()).signalChange(direct(e, false)); 
    3.41        _changeTarget(e,n); 
    3.42 -      getNotifier(UndirEdge()).commitChange(e);
    3.43 -      getNotifier(Edge()).commitChange(direct(e, true)); 
    3.44 -      getNotifier(Edge()).commitChange(direct(e, false)); 
    3.45      }
    3.46      /// Changes the source of \c e to \c n
    3.47      ///
    3.48 @@ -609,13 +597,7 @@
    3.49      ///referencing the changed edge remain
    3.50      ///valid. However <tt>OutEdge</tt>'s are invalidated.
    3.51      void changeSource(UndirEdge e, Node n) { 
    3.52 -      getNotifier(UndirEdge()).signalChange(e); 
    3.53 -      getNotifier(Edge()).signalChange(direct(e, true)); 
    3.54 -      getNotifier(Edge()).signalChange(direct(e, false)); 
    3.55        _changeSource(e,n); 
    3.56 -      getNotifier(UndirEdge()).commitChange(e);
    3.57 -      getNotifier(Edge()).commitChange(direct(e, true)); 
    3.58 -      getNotifier(Edge()).commitChange(direct(e, false)); 
    3.59      }
    3.60      /// \brief Contract two nodes.
    3.61      ///
     4.1 --- a/lemon/smart_graph.h	Fri Oct 14 11:03:40 2005 +0000
     4.2 +++ b/lemon/smart_graph.h	Mon Oct 17 10:28:48 2005 +0000
     4.3 @@ -315,13 +315,7 @@
     4.4      ///\todo It could be implemented in a bit faster way.
     4.5      Node split(Node n, bool connect = true) 
     4.6      {
     4.7 -      for (OutEdgeIt it(*this, n); it != INVALID; ++it) {
     4.8 -	getNotifier(Edge()).signalChange(it);
     4.9 -      }
    4.10        Node b = _split(n,connect);
    4.11 -      for (OutEdgeIt it(*this, b); it != INVALID; ++it) {
    4.12 -	getNotifier(Edge()).commitChange(it);
    4.13 -      }
    4.14        return b;
    4.15      }
    4.16    
     5.1 --- a/test/graph_utils_test.cc	Fri Oct 14 11:03:40 2005 +0000
     5.2 +++ b/test/graph_utils_test.cc	Mon Oct 17 10:28:48 2005 +0000
     5.3 @@ -82,6 +82,7 @@
     5.4      const int edgeNum = 100;
     5.5      ListGraph graph;
     5.6      InDegMap<ListGraph> inDeg(graph);
     5.7 +    OutDegMap<ListGraph> outDeg(graph);
     5.8      std::vector<ListGraph::Node> nodes(nodeNum);
     5.9      for (int i = 0; i < nodeNum; ++i) {
    5.10        nodes[i] = graph.addNode();
    5.11 @@ -95,25 +96,8 @@
    5.12        check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), 
    5.13  	    "Wrong in degree map");
    5.14      }
    5.15 -    for (int i = 0; i < edgeNum; ++i) {
    5.16 -      graph.changeTarget(edges[i], nodes[urandom(nodeNum)]);
    5.17 -    }
    5.18      for (int i = 0; i < nodeNum; ++i) {
    5.19 -      check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
    5.20 -	    "Wrong in degree map");
    5.21 -    }
    5.22 -    for (int i = 0; i < edgeNum; ++i) {
    5.23 -      graph.changeSource(edges[i], nodes[urandom(nodeNum)]);
    5.24 -    }
    5.25 -    for (int i = 0; i < nodeNum; ++i) {
    5.26 -      check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), 
    5.27 -	    "Wrong in degree map");
    5.28 -    }
    5.29 -    for (int i = 0; i < edgeNum; ++i) {
    5.30 -      graph.reverseEdge(edges[i]);
    5.31 -    }
    5.32 -    for (int i = 0; i < nodeNum; ++i) {
    5.33 -      check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), 
    5.34 +      check(outDeg[nodes[i]] == countOutEdges(graph, nodes[i]), 
    5.35  	    "Wrong in degree map");
    5.36      }
    5.37    }