Add a warning for List(Di)Graph::Snapshot (#311)
authorPeter Kovacs <kpeter@inf.elte.hu>
Tue, 29 Sep 2009 10:21:51 +0200
changeset 787819ca5b50de0
parent 785 456fa5bc3256
child 788 10c9c3a35b83
Add a warning for List(Di)Graph::Snapshot (#311)
and extend tests for snapshots
lemon/list_graph.h
test/digraph_test.cc
test/graph_test.cc
     1.1 --- a/lemon/list_graph.h	Sun Aug 23 11:13:21 2009 +0200
     1.2 +++ b/lemon/list_graph.h	Tue Sep 29 10:21:51 2009 +0200
     1.3 @@ -751,6 +751,9 @@
     1.4        ///
     1.5        /// This function undos the changes until the last snapshot
     1.6        /// created by save() or Snapshot(ListDigraph&).
     1.7 +      ///
     1.8 +      /// \warning This method invalidates the snapshot, i.e. repeated
     1.9 +      /// restoring is not supported unless you call save() again.
    1.10        void restore() {
    1.11          detach();
    1.12          for(std::list<Arc>::iterator it = added_arcs.begin();
    1.13 @@ -1550,6 +1553,9 @@
    1.14        ///
    1.15        /// This function undos the changes until the last snapshot
    1.16        /// created by save() or Snapshot(ListGraph&).
    1.17 +      ///
    1.18 +      /// \warning This method invalidates the snapshot, i.e. repeated
    1.19 +      /// restoring is not supported unless you call save() again.
    1.20        void restore() {
    1.21          detach();
    1.22          for(std::list<Edge>::iterator it = added_edges.begin();
     2.1 --- a/test/digraph_test.cc	Sun Aug 23 11:13:21 2009 +0200
     2.2 +++ b/test/digraph_test.cc	Tue Sep 29 10:21:51 2009 +0200
     2.3 @@ -286,6 +286,14 @@
     2.4    G.addArc(G.addNode(), G.addNode());
     2.5  
     2.6    snapshot.restore();
     2.7 +  snapshot.save(G);
     2.8 +
     2.9 +  checkGraphNodeList(G, 4);
    2.10 +  checkGraphArcList(G, 4);
    2.11 +
    2.12 +  G.addArc(G.addNode(), G.addNode());
    2.13 +
    2.14 +  snapshot.restore();
    2.15  
    2.16    checkGraphNodeList(G, 4);
    2.17    checkGraphArcList(G, 4);
     3.1 --- a/test/graph_test.cc	Sun Aug 23 11:13:21 2009 +0200
     3.2 +++ b/test/graph_test.cc	Tue Sep 29 10:21:51 2009 +0200
     3.3 @@ -259,6 +259,15 @@
     3.4    G.addEdge(G.addNode(), G.addNode());
     3.5  
     3.6    snapshot.restore();
     3.7 +  snapshot.save(G);
     3.8 +
     3.9 +  checkGraphNodeList(G, 4);
    3.10 +  checkGraphEdgeList(G, 3);
    3.11 +  checkGraphArcList(G, 6);
    3.12 +  
    3.13 +  G.addEdge(G.addNode(), G.addNode());
    3.14 +
    3.15 +  snapshot.restore();
    3.16  
    3.17    checkGraphNodeList(G, 4);
    3.18    checkGraphEdgeList(G, 3);