From b7f997d3686cdd60a31c9a37a4c85a2875d303b3 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Tue, 11 Apr 2017 16:29:24 -0400 Subject: More splitters --- .../src/main/java/bjc/utils/funcdata/IList.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (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 de48d6f..28c09d0 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java @@ -10,6 +10,7 @@ import java.util.function.Predicate; import java.util.stream.Collector; import bjc.utils.data.IPair; +import bjc.utils.functypes.ID; /** * A wrapper over another list that provides functional operations over it. @@ -315,6 +316,26 @@ public interface IList extends Iterable { BiFunction accumulator, Function transformer); + /** + * Reduce this list to a single value, using a accumulative approach. + * + * @param + * The in-between type of the values. + * + * @param initial + * The initial value of the accumulative state. + * + * @param accumulator + * The function to use to combine a list element with the + * accumulative state. + * + * @return A single value condensed from this list. + */ + default StateType reduceAux(StateType initial, + BiFunction accumulator) { + return reduceAux(initial, accumulator, ID.id()); + } + /** * Remove all elements that match a given predicate * -- cgit v1.2.3