From 0a8f34c27c6ef93c5c94d17728af62c7607e225f Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Thu, 3 Dec 2020 19:21:38 -0500 Subject: Rename types to match Java style This renames several interfaces that had names like IWhatever, since that isn't a style that Java uses --- src/main/java/bjc/funcdata/FunctionalList.java | 50 +++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/main/java/bjc/funcdata/FunctionalList.java') diff --git a/src/main/java/bjc/funcdata/FunctionalList.java b/src/main/java/bjc/funcdata/FunctionalList.java index 2cdfa27..f9c06a3 100644 --- a/src/main/java/bjc/funcdata/FunctionalList.java +++ b/src/main/java/bjc/funcdata/FunctionalList.java @@ -12,10 +12,10 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -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; /** * A wrapper over another list that provides eager functional operations over @@ -29,7 +29,7 @@ import bjc.data.Pair; * @param * The type in this list */ -public class FunctionalList implements Cloneable, IList { +public class FunctionalList implements Cloneable, ListEx { /* The list used as a backing store */ private final List wrapped; @@ -65,7 +65,7 @@ public class FunctionalList implements Cloneable, IList { * @return The returned list. */ @SafeVarargs - public static IList listOf(final T... items) { + public static ListEx listOf(final T... items) { return new FunctionalList<>(items); } @@ -137,8 +137,8 @@ public class FunctionalList implements Cloneable, IList { * @return A copy of the list. */ @Override - public IList clone() { - final IList cloned = new FunctionalList<>(); + public ListEx clone() { + final ListEx cloned = new FunctionalList<>(); for (final E element : wrapped) { cloned.add(element); @@ -148,7 +148,7 @@ public class FunctionalList implements Cloneable, IList { } @Override - public IList combineWith(final IList rightList, + public ListEx combineWith(final ListEx rightList, final BiFunction itemCombiner) { if (rightList == null) { throw new NullPointerException("Target combine list must not be null"); @@ -156,7 +156,7 @@ public class FunctionalList implements Cloneable, IList { throw new NullPointerException("Combiner must not be null"); } - final IList returned = new FunctionalList<>(); + final ListEx returned = new FunctionalList<>(); /* Get the iterator for the other list. */ final Iterator rightIterator = rightList.toIterable().iterator(); @@ -222,14 +222,14 @@ public class FunctionalList implements Cloneable, IList { } @Override - public IList flatMap(final Function> expander) { + public ListEx flatMap(final Function> expander) { if (expander == null) throw new NullPointerException("Expander must not be null"); - final IList returned = new FunctionalList<>(this.wrapped.size()); + final ListEx returned = new FunctionalList<>(this.wrapped.size()); forEach(element -> { - final IList expandedElement = expander.apply(element); + final ListEx expandedElement = expander.apply(element); if (expandedElement == null) throw new NullPointerException("Expander returned null list"); @@ -257,7 +257,7 @@ public class FunctionalList implements Cloneable, IList { /* * This is held b/c ref'd variables must be final/effectively final. */ - final IHolder currentIndex = new Identity<>(0); + final Holder currentIndex = new Identity<>(0); wrapped.forEach(element -> { /* Call the action with the index and the value. */ @@ -283,11 +283,11 @@ public class FunctionalList implements Cloneable, IList { } @Override - public IList getMatching(final Predicate predicate) { + public ListEx getMatching(final Predicate predicate) { if (predicate == null) throw new NullPointerException("Predicate must not be null"); - final IList returned = new FunctionalList<>(); + final ListEx returned = new FunctionalList<>(); wrapped.forEach(element -> { if (predicate.test(element)) { @@ -313,17 +313,17 @@ public class FunctionalList implements Cloneable, IList { /* Check if a partition has room for another item. */ private Boolean isPartitionFull(final int numberPerPartition, - final IHolder> currentPartition) { + final Holder> currentPartition) { return currentPartition .unwrap(partition -> partition.getSize() >= numberPerPartition); } @Override - public IList map(final Function elementTransformer) { + public ListEx map(final Function elementTransformer) { if (elementTransformer == null) throw new NullPointerException("Transformer must be not null"); - final IList returned = new FunctionalList<>(this.wrapped.size()); + final ListEx returned = new FunctionalList<>(this.wrapped.size()); forEach(element -> { // Add the transformed item to the result @@ -334,12 +334,12 @@ public class FunctionalList implements Cloneable, IList { } @Override - public IList> pairWith(final IList rightList) { - return combineWith(rightList, Pair::new); + public ListEx> pairWith(final ListEx rightList) { + return combineWith(rightList, SimplePair::new); } @Override - public IList> partition(final int numberPerPartition) { + public ListEx> partition(final int numberPerPartition) { if (numberPerPartition < 1 || numberPerPartition > wrapped.size()) { final String fmt = "%s is an invalid partition size. Must be between 1 and %d"; @@ -348,10 +348,10 @@ public class FunctionalList implements Cloneable, IList { throw new IllegalArgumentException(msg); } - final IList> returned = new FunctionalList<>(); + final ListEx> returned = new FunctionalList<>(); /* The current partition being filled. */ - final IHolder> currentPartition = new Identity<>(new FunctionalList<>()); + final Holder> currentPartition = new Identity<>(new FunctionalList<>()); this.forEach(element -> { if (isPartitionFull(numberPerPartition, currentPartition)) { @@ -395,7 +395,7 @@ public class FunctionalList implements Cloneable, IList { } /* The current collapsed list. */ - final IHolder currentState = new Identity<>(initialValue); + final Holder currentState = new Identity<>(initialValue); wrapped.forEach(element -> { /* Accumulate a new value into the state. */ @@ -444,7 +444,7 @@ public class FunctionalList implements Cloneable, IList { } @Override - public IList tail() { + public ListEx tail() { return new FunctionalList<>(wrapped.subList(1, getSize())); } -- cgit v1.2.3