From 2b3f20d89c7d500842869d3316bee9c7457ba6d4 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sat, 22 Jul 2017 21:05:57 +0200 Subject: Adds the "is_terminal" predicate. --- cfg-to-paths/src/Path.java | 48 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'cfg-to-paths/src/Path.java') diff --git a/cfg-to-paths/src/Path.java b/cfg-to-paths/src/Path.java index 76ba28a..6015d53 100644 --- a/cfg-to-paths/src/Path.java +++ b/cfg-to-paths/src/Path.java @@ -5,28 +5,6 @@ public class Path private final ArrayList nodes; private final Node last_node; - private Path (final Node start) - { - nodes = new ArrayList(); - - nodes.add(start); - - last_node = start; - } - - private Path (final ArrayList nodes, final Node last_node) - { - this.nodes = nodes; - this.last_node = last_node; - - this.nodes.add(last_node); - } - - private Path add_step (final Node n) - { - return new Path((ArrayList) nodes.clone(), n); - } - public static Collection get_all_paths_from (final String root) { final Collection result; @@ -68,6 +46,10 @@ public class Path } else { + if (current_node.is_terminal()) + { + result.add(current_path); + } for (final Node next: next_nodes) { waiting_list.push(current_path.add_step(next)); @@ -78,6 +60,28 @@ public class Path return result; } + private Path (final Node start) + { + nodes = new ArrayList(); + + nodes.add(start); + + last_node = start; + } + + private Path (final ArrayList nodes, final Node last_node) + { + this.nodes = nodes; + this.last_node = last_node; + + this.nodes.add(last_node); + } + + private Path add_step (final Node n) + { + return new Path((ArrayList) nodes.clone(), n); + } + public Collection> get_all_subpaths () { final Collection> result; -- cgit v1.2.3-70-g09d2