diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-11 16:29:24 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-11 16:29:24 -0400 |
| commit | b7f997d3686cdd60a31c9a37a4c85a2875d303b3 (patch) | |
| tree | ef6de8f9d587c9ed0944a98717f345649462d3cb /BJC-Utils2/src/main/java/bjc/utils/funcdata | |
| parent | 9f619b8de8f2c5da9dff170e2e351cfe57eaebc8 (diff) | |
More splitters
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java | 21 |
1 files changed, 21 insertions, 0 deletions
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. @@ -316,6 +317,26 @@ public interface IList<ContainedType> extends Iterable<ContainedType> { Function<StateType, ReducedType> transformer); /** + * Reduce this list to a single value, using a accumulative approach. + * + * @param <StateType> + * 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> StateType reduceAux(StateType initial, + BiFunction<ContainedType, StateType, StateType> accumulator) { + return reduceAux(initial, accumulator, ID.id()); + } + + /** * Remove all elements that match a given predicate * * @param predicate |
