From b4f5f98c0aa7fc892e96771ff2df729e61c21f74 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 18 Apr 2016 19:56:32 -0400 Subject: Minor code changes --- .../java/bjc/utils/funcdata/FunctionalList.java | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 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 70d04cc..735c664 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/FunctionalList.java @@ -182,8 +182,8 @@ public class FunctionalList implements Cloneable, IFunctionalList { // 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(); @@ -228,18 +228,18 @@ public class FunctionalList implements Cloneable, IFunctionalList { * Function) */ @Override - public IFunctionalList flatMap( - Function> elementExpander) { + public IFunctionalList + flatMap(Function> elementExpander) { if (elementExpander == null) { throw new NullPointerException("Expander must not be null"); } - IFunctionalList returnedList = new FunctionalList<>( - this.wrappedList.size()); + IFunctionalList returnedList = + new FunctionalList<>(this.wrappedList.size()); forEach(element -> { - IFunctionalList expandedElement = elementExpander - .apply(element); + IFunctionalList expandedElement = + elementExpander.apply(element); if (expandedElement == null) { throw new NullPointerException( @@ -370,8 +370,8 @@ public class FunctionalList implements Cloneable, IFunctionalList { throw new NullPointerException("Transformer must be not null"); } - IFunctionalList returnedList = new FunctionalList<>( - this.wrappedList.size()); + IFunctionalList returnedList = + new FunctionalList<>(this.wrappedList.size()); forEach(element -> { // Add the transformed item to the result @@ -388,8 +388,8 @@ public class FunctionalList implements Cloneable, IFunctionalList { * IFunctionalList) */ @Override - public IFunctionalList> pairWith( - IFunctionalList rightList) { + public IFunctionalList> + pairWith(IFunctionalList rightList) { return combineWith(rightList, Pair::new); } @@ -399,8 +399,8 @@ public class FunctionalList implements Cloneable, IFunctionalList { * @see bjc.utils.funcdata.IFunctionalList#partition(int) */ @Override - public IFunctionalList> partition( - int numberPerPartition) { + public IFunctionalList> + partition(int numberPerPartition) { if (numberPerPartition < 1 || numberPerPartition > wrappedList.size()) { throw new IllegalArgumentException("" + numberPerPartition @@ -408,11 +408,12 @@ public class FunctionalList implements Cloneable, IFunctionalList { + wrappedList.size()); } - IFunctionalList> returnedList = new FunctionalList<>(); + IFunctionalList> returnedList = + new FunctionalList<>(); // The current partition being filled - IHolder> currentPartition = new Identity<>( - new FunctionalList<>()); + IHolder> currentPartition = + new Identity<>(new FunctionalList<>()); this.forEach((element) -> { if (isPartitionFull(numberPerPartition, currentPartition)) { @@ -595,4 +596,9 @@ public class FunctionalList implements Cloneable, IFunctionalList { public IFunctionalList tail() { return new FunctionalList<>(wrappedList.subList(1, getSize())); } + + @Override + public void reverse() { + Collections.reverse(wrappedList); + } } \ No newline at end of file -- cgit v1.2.3