public interface PMapX<K,V> extends To<PMapX<K,V>>, org.pcollections.PMap<K,V>, FluentMapX<K,V>, BiFunctor<K,V>, Functor<V>, IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>, OnEmpty<org.jooq.lambda.tuple.Tuple2<K,V>>, OnEmptySwitch<org.jooq.lambda.tuple.Tuple2<K,V>,org.pcollections.PMap<K,V>>, org.reactivestreams.Publisher<org.jooq.lambda.tuple.Tuple2<K,V>>, Foldable<org.jooq.lambda.tuple.Tuple2<K,V>>, CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
Modifier and Type | Method and Description |
---|---|
default <U1,U2> PMapX<U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2)
Cast two data types simulatanously.
|
default <R1,R2> PMapX<R1,R2> |
bimap(java.util.function.Function<? super K,? extends R1> fn1,
java.util.function.Function<? super V,? extends R2> fn2)
Transform this BiFunctor, changing two value types at once.
|
default PMapX<K,V> |
bipeek(java.util.function.Consumer<? super K> c1,
java.util.function.Consumer<? super V> c2)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
default <R1,R2> PMapX<R1,R2> |
bitrampoline(java.util.function.Function<? super K,? extends Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super V,? extends Trampoline<? extends R2>> mapper2)
Perform a tail-call optimized recursive transformation operation across two data points simultaneously
|
default <U> PMapX<K,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
default org.jooq.lambda.Collectable<org.jooq.lambda.tuple.Tuple2<K,V>> |
collectable()
Narrow this class to a Collectable
|
static <K,V> PMapX<K,V> |
empty() |
default PMapX<K,V> |
filter(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Keep only elements for which the supplied predicates hold
e.g.
|
default PMapX<K,V> |
filterNot(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
static <K,V> PMapX<K,V> |
fromMap(java.util.Map<? extends K,? extends V> map) |
default PMapX<K,V> |
fromStream(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> stream) |
default java.util.Iterator<org.jooq.lambda.tuple.Tuple2<K,V>> |
iterator() |
default <R> PMapX<K,R> |
map(java.util.function.Function<? super V,? extends R> fn)
Transform this functor using the supplied transformation function
|
PMapX<K,V> |
minus(java.lang.Object key) |
PMapX<K,V> |
minusAll(java.util.Collection<?> keys) |
default PMapX<K,V> |
notNull()
Filter elements retaining only values which are not null
|
default PMapX<K,V> |
onEmpty(org.jooq.lambda.tuple.Tuple2<K,V> value)
If this Container instance is empty, create a new instance containing the provided value
|
default PMapX<K,V> |
onEmptyGet(java.util.function.Supplier<? extends org.jooq.lambda.tuple.Tuple2<K,V>> supplier)
If this Container instance is empty, create a new instance containing the value returned from the provided Supplier
|
default PMapX<K,V> |
onEmptySwitch(java.util.function.Supplier<? extends org.pcollections.PMap<K,V>> supplier)
Switch to container created by provided Supplier, if current Container empty
|
default <X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
If this container instance is empty, throw the exception returned by the provided Supplier
|
default <R> PMapX<K,R> |
patternMatch(java.util.function.Function<Matchable.CheckValue1<V,R>,Matchable.CheckValue1<V,R>> case1,
java.util.function.Supplier<? extends R> otherwise)
Transform the elements of this Stream with a Pattern Matching case and default value
|
default PMapX<K,V> |
peek(java.util.function.Consumer<? super V> c)
Peek at the current value of this Functor, without transforming it
|
PMapX<K,V> |
plus(K key,
V value) |
PMapX<K,V> |
plusAll(java.util.Map<? extends K,? extends V> map) |
default PMapX<K,V> |
removeAll(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
Remove all elements in the supplied Iterable from this filterable
|
default PMapX<K,V> |
removeAll(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
Remove all elements in the supplied Stream from this filterable
|
default PMapX<K,V> |
removeAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
Remove all supplied elements from this filterable
|
default PMapX<K,V> |
retainAll(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
Retain only the supplied elements in the returned Filterable
|
default PMapX<K,V> |
retainAll(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
Retain only the supplied elements in the returned Filterable
|
default PMapX<K,V> |
retainAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
Retain only the supplied elements in the returned Filterable
|
static <K,V> PMapX<K,V> |
singleton(K key,
V value) |
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> |
stream() |
default void |
subscribe(org.reactivestreams.Subscriber<? super org.jooq.lambda.tuple.Tuple2<K,V>> s) |
default <T> ListX<T> |
toListX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a ListX via the provided transformation function
|
default <T> PBagX<T> |
toPBagX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a PBagX via the provided transformation function
|
default <T> POrderedSetX<T> |
toPOrderedSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a POrderdSetX via the provided transformation function
|
default <T> PQueueX<T> |
toPQueueX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a QueueX via the provided transformation function
|
default <T> PSetX<T> |
toPSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a PSetX via the provided transformation function
|
default <T> PStackX<T> |
toPStackX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a PStackX via the provided transformation function
|
default <T> PVectorX<T> |
toPVectorX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a PVectorX via the provided transformation function
|
default <R> PMapX<K,R> |
trampoline(java.util.function.Function<? super V,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values
ofType
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldable, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleOptional, startsWith, startsWithIterable, toConcurrentLazyCollection, toConcurrentLazyStreamable, toLazyCollection, validate, xMatch
allMatch, anyMatch, avg, avg, avgDouble, avgInt, avgLong, bitAnd, bitAnd, bitAndInt, bitAndLong, bitOr, bitOr, bitOrInt, bitOrLong, collect, commonPrefix, commonSuffix, count, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, max, max, max, max, maxAll, maxAll, maxAll, maxAll, maxAllBy, maxAllBy, maxBy, maxBy, median, median, medianBy, medianBy, min, min, min, min, minAll, minAll, minAll, minAll, minAllBy, minAllBy, minBy, minBy, mode, modeAll, modeAllBy, modeBy, noneMatch, percentile, percentile, percentileBy, percentileBy, sum, sum, sumDouble, sumInt, sumLong, toCollection, toList, toList, toMap, toMap, toSet, toSet, toString, toString
static <K,V> PMapX<K,V> empty()
static <K,V> PMapX<K,V> singleton(K key, V value)
static <K,V> PMapX<K,V> fromMap(java.util.Map<? extends K,? extends V> map)
default org.jooq.lambda.Collectable<org.jooq.lambda.tuple.Tuple2<K,V>> collectable()
CyclopsCollectable
collectable
in interface CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> stream()
stream
in interface Foldable<org.jooq.lambda.tuple.Tuple2<K,V>>
ReactiveSeq
) of it's elementsdefault <R> PMapX<K,R> map(java.util.function.Function<? super V,? extends R> fn)
Functor
of(1,2,3).map(i->i*2)
//[2,4,6]
default <R1,R2> PMapX<R1,R2> bimap(java.util.function.Function<? super K,? extends R1> fn1, java.util.function.Function<? super V,? extends R2> fn2)
BiFunctor
MapX<String,Integer> map = MapXs.of("hello",2);
MapX<String,Integer> transformedMap = map.bimap(s->s+" world",i->i*4);
//["hello world",8]
default PMapX<K,V> bipeek(java.util.function.Consumer<? super K> c1, java.util.function.Consumer<? super V> c2)
BiFunctor
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
default <U1,U2> PMapX<U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
BiFunctor
MapX<Animal,Food> map = MapXs.of(cow,grass);
MapX<Mamaml,Vegitation> herbervoreMammals = map.bicast(Mammal.class,Vegitation.class);
default <R1,R2> PMapX<R1,R2> bitrampoline(java.util.function.Function<? super K,? extends Trampoline<? extends R1>> mapper1, java.util.function.Function<? super V,? extends Trampoline<? extends R2>> mapper2)
BiFunctor
bitrampoline
in interface BiFunctor<K,V>
mapper1
- transformation function for the first typemapper2
- transformation function for the second typedefault <U> PMapX<K,U> cast(java.lang.Class<? extends U> type)
Functor
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)default PMapX<K,V> peek(java.util.function.Consumer<? super V> c)
Functor
of(1,2,3).map(System.out::println)
1
2
3
default <R> PMapX<K,R> trampoline(java.util.function.Function<? super V,? extends Trampoline<? extends R>> mapper)
Functor
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
trampoline
in interface Functor<V>
mapper
- TCO Transformation functiondefault PMapX<K,V> filter(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Filterable
of(1,2,3).filter(i->i>2);
//[3]
filter
in interface Filterable<org.jooq.lambda.tuple.Tuple2<K,V>>
fn
- to filter elements by, retaining matchesdefault PMapX<K,V> filterNot(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Filterable
of(1,2,3).filter(i->i>2);
//[1,2]
filterNot
in interface Filterable<org.jooq.lambda.tuple.Tuple2<K,V>>
fn
- to filter elements by, retaining matchesdefault PMapX<K,V> notNull()
Filterable
of(1,2,null,4).nonNull();
//[1,2,4]
notNull
in interface Filterable<org.jooq.lambda.tuple.Tuple2<K,V>>
default PMapX<K,V> removeAll(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
IterableFilterable
removeAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
stream
- of elements to removedefault PMapX<K,V> removeAll(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
IterableFilterable
removeAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
it
- an Iterable of elements to removedefault PMapX<K,V> removeAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
IterableFilterable
removeAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
values
- to removedefault PMapX<K,V> retainAll(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
IterableFilterable
retainAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
it
- Iterable of elements to retaindefault PMapX<K,V> retainAll(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
IterableFilterable
retainAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
stream
- of elements to retaindefault PMapX<K,V> retainAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
IterableFilterable
retainAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
values
- elements to retaindefault <R> PMapX<K,R> patternMatch(java.util.function.Function<Matchable.CheckValue1<V,R>,Matchable.CheckValue1<V,R>> case1, java.util.function.Supplier<? extends R> otherwise)
Functor
List<String> result = CollectionX.of(1,2,3,4)
.patternMatch(
c->c.valuesWhere(i->"even", (Integer i)->i%2==0 )
)
// CollectionX["odd","even","odd","even"]
patternMatch
in interface Functor<V>
case1
- Function to generate a case (or chain of cases as a single case)otherwise
- Value if supplied case doesn't matchdefault void subscribe(org.reactivestreams.Subscriber<? super org.jooq.lambda.tuple.Tuple2<K,V>> s)
default PMapX<K,V> onEmpty(org.jooq.lambda.tuple.Tuple2<K,V> value)
OnEmpty
default PMapX<K,V> onEmptyGet(java.util.function.Supplier<? extends org.jooq.lambda.tuple.Tuple2<K,V>> supplier)
OnEmpty
onEmptyGet
in interface OnEmpty<org.jooq.lambda.tuple.Tuple2<K,V>>
supplier
- to determine new value for containerdefault <X extends java.lang.Throwable> PMapX<K,V> onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
OnEmpty
onEmptyThrow
in interface OnEmpty<org.jooq.lambda.tuple.Tuple2<K,V>>
supplier
- to create exception fromdefault PMapX<K,V> onEmptySwitch(java.util.function.Supplier<? extends org.pcollections.PMap<K,V>> supplier)
OnEmptySwitch
ListX.empty().onEmptySwitch(()->ListX.of(1));
onEmptySwitch
in interface OnEmptySwitch<org.jooq.lambda.tuple.Tuple2<K,V>,org.pcollections.PMap<K,V>>
supplier
- to create replacement containerdefault <T> ListX<T> toListX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> PSetX<T> toPSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> POrderedSetX<T> toPOrderedSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> PQueueX<T> toPQueueX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> PStackX<T> toPStackX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> PVectorX<T> toPVectorX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> PBagX<T> toPBagX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single value