slight generalization of duplicate to add copyInto
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1036 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
9cdd4f4791
commit
b120c59abf
|
@ -70,15 +70,19 @@ public class SlowSparseNumberedGraph<T> extends AbstractNumberedGraph<T> {
|
|||
*/
|
||||
public static <T> SlowSparseNumberedGraph<T> duplicate(Graph<T> g) {
|
||||
SlowSparseNumberedGraph<T> result = new SlowSparseNumberedGraph<T>();
|
||||
copyInto(g, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> void copyInto(Graph<T> g, Graph<T> into) {
|
||||
for (Iterator<? extends T> it = g.iterator(); it.hasNext();) {
|
||||
result.addNode(it.next());
|
||||
into.addNode(it.next());
|
||||
}
|
||||
for (Iterator<? extends T> it = g.iterator(); it.hasNext();) {
|
||||
T n = it.next();
|
||||
for (Iterator<? extends T> it2 = g.getSuccNodes(n); it2.hasNext();) {
|
||||
result.addEdge(n, it2.next());
|
||||
into.addEdge(n, it2.next());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue