From a2c7425458f645802a352abc4783e0afc73dba13 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Thu, 3 Dec 2020 19:22:35 -0500 Subject: Adapt to esodata changes --- .../java/bjc/utils/funcutils/CollectorUtils.java | 8 ++--- .../bjc/utils/funcutils/CompoundCollector.java | 22 ++++++------- .../main/java/bjc/utils/funcutils/EnumUtils.java | 4 +-- .../java/bjc/utils/funcutils/IteratorUtils.java | 4 +-- .../main/java/bjc/utils/funcutils/ListUtils.java | 38 +++++++++++----------- .../main/java/bjc/utils/funcutils/TreeUtils.java | 22 ++++++------- 6 files changed, 49 insertions(+), 49 deletions(-) (limited to 'base/src/main/java/bjc/utils/funcutils') diff --git a/base/src/main/java/bjc/utils/funcutils/CollectorUtils.java b/base/src/main/java/bjc/utils/funcutils/CollectorUtils.java index 81313c8..a92c2d1 100644 --- a/base/src/main/java/bjc/utils/funcutils/CollectorUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/CollectorUtils.java @@ -2,8 +2,8 @@ package bjc.utils.funcutils; import java.util.stream.Collector; -import bjc.data.IHolder; -import bjc.data.IPair; +import bjc.data.Holder; +import bjc.data.Pair; /** * Utilities for producing implementations of {@link Collector} @@ -38,8 +38,8 @@ public class CollectorUtils { * @return A collector that functions as mentioned above. */ public static - Collector>, - IPair> + Collector>, + Pair> compoundCollect(final Collector first, final Collector second) { return new CompoundCollector<>(first, second); diff --git a/base/src/main/java/bjc/utils/funcutils/CompoundCollector.java b/base/src/main/java/bjc/utils/funcutils/CompoundCollector.java index 5e51c20..5aa266e 100644 --- a/base/src/main/java/bjc/utils/funcutils/CompoundCollector.java +++ b/base/src/main/java/bjc/utils/funcutils/CompoundCollector.java @@ -7,10 +7,10 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collector; -import bjc.data.IHolder; -import bjc.data.IPair; -import bjc.data.Identity; +import bjc.data.Holder; import bjc.data.Pair; +import bjc.data.Identity; +import bjc.data.SimplePair; /** * Implementation of a collecter that uses two collectors. @@ -18,8 +18,8 @@ import bjc.data.Pair; * @author Ben Culkin */ final class CompoundCollector - implements Collector>, - IPair> { + implements Collector>, + Pair> { /* Our characteristics. */ private final Set characteristicSet; @@ -48,7 +48,7 @@ final class CompoundCollector>, InitialType> accumulator() { + public BiConsumer>, InitialType> accumulator() { final BiConsumer firstAccumulator = first.accumulator(); final BiConsumer secondAccumulator = second.accumulator(); @@ -68,7 +68,7 @@ final class CompoundCollector>> combiner() { + public BinaryOperator>> combiner() { final BinaryOperator firstCombiner = first.combiner(); final BinaryOperator secondCombiner = second.combiner(); @@ -80,25 +80,25 @@ final class CompoundCollector>, IPair> + public Function>, Pair> finisher() { return state -> state.unwrap(pair -> { return pair.bind((left, right) -> { final FinalType1 finalLeft = first.finisher().apply(left); final FinalType2 finalRight = second.finisher().apply(right); - return new Pair<>(finalLeft, finalRight); + return new SimplePair<>(finalLeft, finalRight); }); }); } @Override - public Supplier>> supplier() { + public Supplier>> supplier() { return () -> { final AuxType1 initialLeft = first.supplier().get(); final AuxType2 initialRight = second.supplier().get(); - return new Identity<>(new Pair<>(initialLeft, initialRight)); + return new Identity<>(new SimplePair<>(initialLeft, initialRight)); }; } } diff --git a/base/src/main/java/bjc/utils/funcutils/EnumUtils.java b/base/src/main/java/bjc/utils/funcutils/EnumUtils.java index e8898ca..6d53952 100644 --- a/base/src/main/java/bjc/utils/funcutils/EnumUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/EnumUtils.java @@ -4,7 +4,7 @@ import java.util.Random; import java.util.function.Consumer; import bjc.funcdata.FunctionalList; -import bjc.funcdata.IList; +import bjc.funcdata.ListEx; /** * Utility methods on enums. @@ -34,7 +34,7 @@ public class EnumUtils { final int nValues, final Consumer action, final Random rnd) { final E[] enumValues = clasz.getEnumConstants(); - final IList valueList = new FunctionalList<>(enumValues); + final ListEx valueList = new FunctionalList<>(enumValues); final int randomValueCount = enumValues.length - nValues; diff --git a/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java b/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java index ea67295..662b1bf 100644 --- a/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/IteratorUtils.java @@ -107,9 +107,9 @@ public class IteratorUtils { * yields the consumed values. */ public static - IPair, Iterator> entangle() + Pair, Iterator> entangle() { Queue backer = new ArrayDeque<>(); - return IPair.pair(backer::add, new QueueBackedIterator<>(backer)); + return Pair.pair(backer::add, new QueueBackedIterator<>(backer)); } } diff --git a/base/src/main/java/bjc/utils/funcutils/ListUtils.java b/base/src/main/java/bjc/utils/funcutils/ListUtils.java index e3662af..17642ce 100644 --- a/base/src/main/java/bjc/utils/funcutils/ListUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/ListUtils.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.function.*; import bjc.funcdata.FunctionalList; -import bjc.funcdata.IList; +import bjc.funcdata.ListEx; /** * Utilities for manipulating FunctionalLists and regular Collections lists that @@ -27,7 +27,7 @@ public class ListUtils { * * @return The collapsed string of tokens. */ - public static String collapseTokens(final IList input) { + public static String collapseTokens(final ListEx input) { if (input == null) throw new NullPointerException("Input must not be null"); return collapseTokens(input, ""); @@ -45,7 +45,7 @@ public class ListUtils { * * @return The collapsed string of tokens. */ - public static String collapseTokens(final IList input, + public static String collapseTokens(final ListEx input, final String seperator) { if (input == null) throw new NullPointerException("Input must not be null"); else if (seperator == null) throw new NullPointerException("Seperator must not be null"); @@ -89,9 +89,9 @@ public class ListUtils { * @return A new list containing the desired number of items randomly selected * from the specified list without replacement. */ - public static IList drawWithoutReplacement(final IList list, + public static ListEx drawWithoutReplacement(final ListEx list, final int number, final Function rng) { - final IList selected = new FunctionalList<>(new ArrayList<>(number)); + final ListEx selected = new FunctionalList<>(new ArrayList<>(number)); final int total = list.getSize(); @@ -133,9 +133,9 @@ public class ListUtils { * @return A new list containing the desired number of items randomly selected * from the specified list. */ - public static IList drawWithReplacement(final IList list, final int number, + public static ListEx drawWithReplacement(final ListEx list, final int number, final Function rng) { - final IList selected = new FunctionalList<>(new ArrayList<>(number)); + final ListEx selected = new FunctionalList<>(new ArrayList<>(number)); for (int i = 0; i < number; i++) selected.add(list.randItem(rng)); @@ -161,7 +161,7 @@ public class ListUtils { * * @return A list partitioned according to the above rules. */ - public static IList> groupPartition(final IList input, + public static ListEx> groupPartition(final ListEx input, final Function counter, final int partitionSize) { if (input == null) { throw new NullPointerException("Input list must not be null"); @@ -176,10 +176,10 @@ public class ListUtils { } /* List that holds our results. */ - final IList> returned = new FunctionalList<>(); + final ListEx> returned = new FunctionalList<>(); /* List that holds elements rejected during current pass. */ - final IList rejected = new FunctionalList<>(); + final ListEx rejected = new FunctionalList<>(); final GroupPartIteration it = new GroupPartIteration<>(returned, rejected, partitionSize, counter); @@ -215,10 +215,10 @@ public class ListUtils { * @return A list containing all the elements of the lists. */ @SafeVarargs - public static IList mergeLists(final IList... lists) { - final IList returned = new FunctionalList<>(); + public static ListEx mergeLists(final ListEx... lists) { + final ListEx returned = new FunctionalList<>(); - for (final IList list : lists) { + for (final ListEx list : lists) { for (final E itm : list.toIterable()) returned.add(itm); } @@ -249,12 +249,12 @@ public class ListUtils { * If the list couldn't be padded to the * desired size. */ - public static IList padList(final IList list, + public static ListEx padList(final ListEx list, final Function counter, final int size, final Supplier padder) { int count = 0; - final IList returned = new FunctionalList<>(); + final ListEx returned = new FunctionalList<>(); for (final E itm : list.toIterable()) { count += counter.apply(itm); @@ -433,12 +433,12 @@ public class ListUtils { */ class GroupPartIteration implements Consumer { /* The list we're returning. */ - private final IList> returnedList; + private final ListEx> returnedList; /* The current partition of the list. */ - public IList currentPartition; + public ListEx currentPartition; /* The items rejected from the current partition. */ - private final IList rejectedItems; + private final ListEx rejectedItems; /* The number of items in the current partition. */ private int numberInCurrentPartition; @@ -465,7 +465,7 @@ class GroupPartIteration implements Consumer { * @param eleCount * The function to use to determine the value of an item. */ - public GroupPartIteration(final IList> returned, final IList rejects, + public GroupPartIteration(final ListEx> returned, final ListEx rejects, final int nPerPart, final Function eleCount) { this.returnedList = returned; this.rejectedItems = rejects; 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 IList> outlineTree(ITree tre, Predicate leafMarker) { - IList> paths = new FunctionalList<>(); + public static ListEx> outlineTree(Tree tre, Predicate leafMarker) { + ListEx> paths = new FunctionalList<>(); LinkedList path = new LinkedList<>(); path.add(tre.getHead()); @@ -33,11 +33,11 @@ public class TreeUtils { } /* Find a path in a tree. */ - private static void findPath(ITree subtree, LinkedList path, - Predicate leafMarker, IList> paths) { + private static void findPath(Tree subtree, LinkedList path, + Predicate leafMarker, ListEx> paths) { if (subtree.getChildrenCount() == 0 && leafMarker.test(subtree.getHead())) { /* We're at a matching leaf node. Add it. */ - IList finalPath = new FunctionalList<>(); + ListEx 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 ITree substitute( - ITree tree, + public static Tree substitute( + Tree tree, Predicate marker, - Function> expander) { + Function> 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 ITree substitute( - ITree tree, - IMap> environment) { + public static Tree substitute( + Tree tree, + MapEx> environment) { return substitute( tree, environment::containsKey, -- cgit v1.2.3