From dca8e9f586fd595a7995f07788318fb92b8cce79 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 28 Jul 2016 16:44:36 -0400 Subject: Format/Cleanup pass --- .../src/main/java/bjc/utils/funcdata/IList.java | 78 +++++++++++----------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java index 00ec653..e446b64 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java @@ -49,6 +49,29 @@ public interface IList { */ boolean anyMatch(Predicate matchPredicate); + /** + * Reduce the contents of this list using a collector + * + * @param + * The intermediate accumulation type + * @param + * The final, reduced type + * @param collector + * The collector to use for reduction + * @return The reduced list + */ + public default ReducedType collect( + Collector collector) { + BiConsumer accumulator = collector + .accumulator(); + + return reduceAux(collector.supplier().get(), (value, state) -> { + accumulator.accept(state, value); + + return state; + }, collector.finisher()); + } + /** * Combine this list with another one into a new list and merge the * results. Works sort of like a combined zip/map over resulting pairs. @@ -136,8 +159,8 @@ public interface IList { * The predicate to match by * @return A list containing all elements that match the predicate */ - IList - getMatching(Predicate matchPredicate); + IList getMatching( + Predicate matchPredicate); /** * Retrieve the size of the wrapped list @@ -164,8 +187,8 @@ public interface IList { * The function to apply to each element in the list * @return A new list containing the mapped elements of this list. */ - IList - map(Function elementTransformer); + IList map( + Function elementTransformer); /** * Zip two lists into a list of pairs @@ -178,8 +201,8 @@ public interface IList { * @return A list containing pairs of this element and the specified * list */ - IList> - pairWith(IList rightList); + IList> pairWith( + IList rightList); /** * Partition this list into a list of sublists @@ -198,16 +221,6 @@ public interface IList { */ void prepend(ContainedType item); - /** - * Select a random item from this list, using the provided random - * number generator. - * - * @param rnd - * The random number generator to use. - * @return A random element from this list. - */ - ContainedType randItem(Function rnd); - /** * Select a random item from the list, using a default random number * generator @@ -218,6 +231,16 @@ public interface IList { return randItem((num) -> (int) (Math.random() * num)); } + /** + * Select a random item from this list, using the provided random + * number generator. + * + * @param rnd + * The random number generator to use. + * @return A random element from this list. + */ + ContainedType randItem(Function rnd); + /** * Reduce this list to a single value, using a accumulative approach. * @@ -310,27 +333,4 @@ public interface IList { * @return An iterable view onto the list */ public Iterable toIterable(); - - /** - * Reduce the contents of this list using a collector - * - * @param - * The intermediate accumulation type - * @param - * The final, reduced type - * @param collector - * The collector to use for reduction - * @return The reduced list - */ - public default ReducedType collect( - Collector collector) { - BiConsumer accumulator = - collector.accumulator(); - - return reduceAux(collector.supplier().get(), (value, state) -> { - accumulator.accept(state, value); - - return state; - }, collector.finisher()); - } } \ No newline at end of file -- cgit v1.2.3