diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2020-12-14 19:29:37 -0400 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2020-12-14 19:29:37 -0400 |
| commit | 9351ea3e97bbe2d348aa17067ccc6267dc7c080f (patch) | |
| tree | dd2269c26161c735d94d8dc83d56e6076c2a155d /base/src/main/java/bjc/utils/funcutils/TreeUtils.java | |
| parent | 8933de7f646f0565edf700aa2f2fcab06d639855 (diff) | |
| parent | 6dcadc360dafdd12142d53327f44579379a4c9dd (diff) | |
Merge branch 'master' of https://github.com/bculkin2442/bjc-utils2
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/TreeUtils.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/funcutils/TreeUtils.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/TreeUtils.java b/base/src/main/java/bjc/utils/funcutils/TreeUtils.java index 59f60a2..41a01d8 100644 --- a/base/src/main/java/bjc/utils/funcutils/TreeUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/TreeUtils.java @@ -21,8 +21,8 @@ public class TreeUtils { * The path to mark nodes with. * @return The list of marked paths. */ - public static <T> IList<IList<T>> outlineTree(ITree<T> tre, Predicate<T> leafMarker) { - IList<IList<T>> paths = new FunctionalList<>(); + public static <T> ListEx<ListEx<T>> outlineTree(Tree<T> tre, Predicate<T> leafMarker) { + ListEx<ListEx<T>> paths = new FunctionalList<>(); LinkedList<T> path = new LinkedList<>(); path.add(tre.getHead()); @@ -33,11 +33,11 @@ public class TreeUtils { } /* Find a path in a tree. */ - private static <T> void findPath(ITree<T> subtree, LinkedList<T> path, - Predicate<T> leafMarker, IList<IList<T>> paths) { + private static <T> void findPath(Tree<T> subtree, LinkedList<T> path, + Predicate<T> leafMarker, ListEx<ListEx<T>> paths) { if (subtree.getChildrenCount() == 0 && leafMarker.test(subtree.getHead())) { /* We're at a matching leaf node. Add it. */ - IList<T> finalPath = new FunctionalList<>(); + ListEx<T> finalPath = new FunctionalList<>(); for (T ePath : path) finalPath.add(ePath); @@ -63,10 +63,10 @@ public class TreeUtils { * @param expander The function to expand nodes. * @return A transformed copy of the tree. */ - public static <ContainedType> ITree<ContainedType> substitute( - ITree<ContainedType> tree, + public static <ContainedType> Tree<ContainedType> substitute( + Tree<ContainedType> tree, Predicate<ContainedType> marker, - Function<ContainedType, ITree<ContainedType>> expander) { + Function<ContainedType, Tree<ContainedType>> expander) { tree.topDownTransform((contents) -> { if (marker.test(contents)) return TopDownTransformResult.TRANSFORM; else return TopDownTransformResult.PASSTHROUGH; @@ -84,9 +84,9 @@ public class TreeUtils { * @param environment A map which contains the variables to substitute. * @return A transformed copy of the tree. */ - public static <ContainedType> ITree<ContainedType> substitute( - ITree<ContainedType> tree, - IMap<ContainedType, ITree<ContainedType>> environment) { + public static <ContainedType> Tree<ContainedType> substitute( + Tree<ContainedType> tree, + MapEx<ContainedType, Tree<ContainedType>> environment) { return substitute( tree, environment::containsKey, |
