T
- Component type of this foldablepublic interface Foldable<T>
Example:
// = "123"
Stream.of("1", "2", "3").fold("", (a1, a2) -> a1 + a2);
Modifier and Type | Method and Description |
---|---|
default T |
fold(T zero,
BiFunction<? super T,? super T,? extends T> combine)
Folds this elements from the left, starting with
zero and successively calling combine . |
<U> U |
foldLeft(U zero,
BiFunction<? super U,? super T,? extends U> combine)
Folds this elements from the left, starting with
zero and successively calling combine . |
<U> U |
foldRight(U zero,
BiFunction<? super T,? super U,? extends U> combine)
Folds this elements from the right, starting with
zero and successively calling combine . |
default T |
reduce(BiFunction<? super T,? super T,? extends T> op)
Accumulates the elements of this Foldable by successively calling the given operation
op . |
T |
reduceLeft(BiFunction<? super T,? super T,? extends T> op)
Accumulates the elements of this Foldable by successively calling the given operation
op from the left. |
Option<T> |
reduceLeftOption(BiFunction<? super T,? super T,? extends T> op)
Accumulates the elements of this Foldable by successively calling the given operation
op from the left. |
default Option<T> |
reduceOption(BiFunction<? super T,? super T,? extends T> op)
Accumulates the elements of this Foldable by successively calling the given operation
op . |
T |
reduceRight(BiFunction<? super T,? super T,? extends T> op)
Accumulates the elements of this Foldable by successively calling the given operation
op from the right. |
Option<T> |
reduceRightOption(BiFunction<? super T,? super T,? extends T> op)
Accumulates the elements of this Foldable by successively calling the given operation
op from the right. |
default T fold(T zero, BiFunction<? super T,? super T,? extends T> combine)
zero
and successively calling combine
.zero
- A zero element to start with.combine
- A function which combines elements.NullPointerException
- if combine
is null<U> U foldLeft(U zero, BiFunction<? super U,? super T,? extends U> combine)
zero
and successively calling combine
.U
- the type to fold overzero
- A zero element to start with.combine
- A function which combines elements.NullPointerException
- if combine
is null<U> U foldRight(U zero, BiFunction<? super T,? super U,? extends U> combine)
zero
and successively calling combine
.U
- the type of the folded valuezero
- A zero element to start with.combine
- A function which combines elements.NullPointerException
- if combine
is nulldefault T reduce(BiFunction<? super T,? super T,? extends T> op)
op
.
The order of element iteration is undetermined.op
- A BiFunction of type TNoSuchElementException
- if this is emptyNullPointerException
- if op
is nulldefault Option<T> reduceOption(BiFunction<? super T,? super T,? extends T> op)
op
.
The order of element iteration is undetermined.op
- A BiFunction of type TNullPointerException
- if op
is nullT reduceLeft(BiFunction<? super T,? super T,? extends T> op)
op
from the left.op
- A BiFunction of type TNoSuchElementException
- if this is emptyNullPointerException
- if op
is nullOption<T> reduceLeftOption(BiFunction<? super T,? super T,? extends T> op)
op
from the left.op
- A BiFunction of type TNullPointerException
- if op
is nullT reduceRight(BiFunction<? super T,? super T,? extends T> op)
op
from the right.op
- An operation of type TNoSuchElementException
- if this is emptyNullPointerException
- if op
is nullOption<T> reduceRightOption(BiFunction<? super T,? super T,? extends T> op)
op
from the right.op
- An operation of type TNullPointerException
- if op
is nullCopyright © 2016. All Rights Reserved.