public interface BiFunctor<T1,T2>
Modifier and Type | Method and Description |
---|---|
default <U1,U2> BiFunctor<U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
<R1,R2> BiFunctor<R1,R2> |
bimap(java.util.function.Function<? super T1,? extends R1> fn1,
java.util.function.Function<? super T2,? extends R2> fn2) |
default BiFunctor<T1,T2> |
bipeek(java.util.function.Consumer<? super T1> c1,
java.util.function.Consumer<? super T2> c2) |
default <R1,R2> BiFunctor<R1,R2> |
bitrampoline(java.util.function.Function<? super T1,? extends Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super T2,? extends Trampoline<? extends R2>> mapper2)
Performs a map operation that can call a recursive method without running out of stack space
|
<R1,R2> BiFunctor<R1,R2> bimap(java.util.function.Function<? super T1,? extends R1> fn1, java.util.function.Function<? super T2,? extends R2> fn2)
default BiFunctor<T1,T2> bipeek(java.util.function.Consumer<? super T1> c1, java.util.function.Consumer<? super T2> c2)
default <U1,U2> BiFunctor<U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)default <R1,R2> BiFunctor<R1,R2> bitrampoline(java.util.function.Function<? super T1,? extends Trampoline<? extends R1>> mapper1, java.util.function.Function<? super T2,? extends Trampoline<? extends R2>> mapper2)
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
mapper
-