From 79d3a4a47cbc1fcf17c77c6fc12ff826a3077bac Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 6 Apr 2016 13:50:00 -0400 Subject: Minor bugfixes/changes, as well as beginnings of CLI systems --- .../java/bjc/utils/funcdata/FunctionalList.java | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java index ff02515..c680879 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java @@ -207,8 +207,8 @@ public class FunctionalList implements Cloneable { // Get the iterator for the other list Iterator rightIterator = rightList.toIterable().iterator(); - for (Iterator leftIterator = - wrappedList.iterator(); leftIterator.hasNext() + for (Iterator leftIterator = wrappedList + .iterator(); leftIterator.hasNext() && rightIterator.hasNext();) { // Add the transformed items to the result list E leftVal = leftIterator.next(); @@ -258,18 +258,18 @@ public class FunctionalList implements Cloneable { * @return A new list containing the flattened results of applying the * provided function. */ - public FunctionalList - flatMap(Function> elementExpander) { + public FunctionalList flatMap( + Function> elementExpander) { if (elementExpander == null) { throw new NullPointerException("Expander must not be null"); } - FunctionalList returnedList = - new FunctionalList<>(this.wrappedList.size()); + FunctionalList returnedList = new FunctionalList<>( + this.wrappedList.size()); forEach(element -> { - FunctionalList expandedElement = - elementExpander.apply(element); + FunctionalList expandedElement = elementExpander + .apply(element); if (expandedElement == null) { throw new NullPointerException( @@ -400,8 +400,8 @@ public class FunctionalList implements Cloneable { throw new NullPointerException("Transformer must be not null"); } - FunctionalList returnedList = - new FunctionalList<>(this.wrappedList.size()); + FunctionalList returnedList = new FunctionalList<>( + this.wrappedList.size()); forEach(element -> { // Add the transformed item to the result @@ -422,8 +422,8 @@ public class FunctionalList implements Cloneable { * @return A list containing pairs of this element and the specified * list */ - public FunctionalList> - pairWith(FunctionalList rightList) { + public FunctionalList> pairWith( + FunctionalList rightList) { return combineWith(rightList, Pair::new); } @@ -434,8 +434,8 @@ public class FunctionalList implements Cloneable { * The size of elements to put into each one of the sublists * @return A list partitioned into partitions of size nPerPart */ - public FunctionalList> - partition(int numberPerPartition) { + public FunctionalList> partition( + int numberPerPartition) { if (numberPerPartition < 1 || numberPerPartition > wrappedList.size()) { throw new IllegalArgumentException("" + numberPerPartition @@ -443,12 +443,11 @@ public class FunctionalList implements Cloneable { + wrappedList.size()); } - FunctionalList> returnedList = - new FunctionalList<>(); + FunctionalList> returnedList = new FunctionalList<>(); // The current partition being filled - GenHolder> currentPartition = - new GenHolder<>(new FunctionalList<>()); + GenHolder> currentPartition = new GenHolder<>( + new FunctionalList<>()); this.forEach((element) -> { if (isPartitionFull(numberPerPartition, currentPartition)) { @@ -593,10 +592,10 @@ public class FunctionalList implements Cloneable { if (foundIndex >= 0) { // We found a matching element return wrappedList.get(foundIndex); - } else { - // We didn't find an element - return null; } + + // We didn't find an element + return null; } /** -- cgit v1.2.3