[Lemon-commits] Peter Kovacs: Add a warning for List(Di)Graph::S...
Lemon HG
hg at lemon.cs.elte.hu
Wed Sep 30 08:52:47 CEST 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/819ca5b50de0
changeset: 791:819ca5b50de0
user: Peter Kovacs <kpeter [at] inf.elte.hu>
date: Tue Sep 29 10:21:51 2009 +0200
description:
Add a warning for List(Di)Graph::Snapshot (#311) and extend tests
for snapshots
diffstat:
lemon/list_graph.h | 6 ++++++
test/digraph_test.cc | 8 ++++++++
test/graph_test.cc | 9 +++++++++
3 files changed, 23 insertions(+), 0 deletions(-)
diffs (60 lines):
diff --git a/lemon/list_graph.h b/lemon/list_graph.h
--- a/lemon/list_graph.h
+++ b/lemon/list_graph.h
@@ -751,6 +751,9 @@
///
/// This function undos the changes until the last snapshot
/// created by save() or Snapshot(ListDigraph&).
+ ///
+ /// \warning This method invalidates the snapshot, i.e. repeated
+ /// restoring is not supported unless you call save() again.
void restore() {
detach();
for(std::list<Arc>::iterator it = added_arcs.begin();
@@ -1550,6 +1553,9 @@
///
/// This function undos the changes until the last snapshot
/// created by save() or Snapshot(ListGraph&).
+ ///
+ /// \warning This method invalidates the snapshot, i.e. repeated
+ /// restoring is not supported unless you call save() again.
void restore() {
detach();
for(std::list<Edge>::iterator it = added_edges.begin();
diff --git a/test/digraph_test.cc b/test/digraph_test.cc
--- a/test/digraph_test.cc
+++ b/test/digraph_test.cc
@@ -286,6 +286,14 @@
G.addArc(G.addNode(), G.addNode());
snapshot.restore();
+ snapshot.save(G);
+
+ checkGraphNodeList(G, 4);
+ checkGraphArcList(G, 4);
+
+ G.addArc(G.addNode(), G.addNode());
+
+ snapshot.restore();
checkGraphNodeList(G, 4);
checkGraphArcList(G, 4);
diff --git a/test/graph_test.cc b/test/graph_test.cc
--- a/test/graph_test.cc
+++ b/test/graph_test.cc
@@ -259,6 +259,15 @@
G.addEdge(G.addNode(), G.addNode());
snapshot.restore();
+ snapshot.save(G);
+
+ checkGraphNodeList(G, 4);
+ checkGraphEdgeList(G, 3);
+ checkGraphArcList(G, 6);
+
+ G.addEdge(G.addNode(), G.addNode());
+
+ snapshot.restore();
checkGraphNodeList(G, 4);
checkGraphEdgeList(G, 3);
More information about the Lemon-commits
mailing list