K - the type of Entry keysV - the type of Entry valuespublic class EntryStream<K,V> extends AbstractStreamEx<Map.Entry<K,V>,EntryStream<K,V>>
Stream of Map.Entry objects which provides additional specific
functionality.
While EntryStream implements Iterable, it is not a
general-purpose Iterable as it supports only a single
Iterator; invoking the iterator method to obtain a
second or subsequent iterator throws IllegalStateException.
Stream.Builder<T>| Modifier and Type | Method and Description |
|---|---|
EntryStream<K,V> |
append(K key,
V value)
Returns a new
EntryStream which is a concatenation of this stream
and the supplied key-value pair. |
EntryStream<K,V> |
append(K k1,
V v1,
K k2,
V v2)
Returns a new
EntryStream which is a concatenation of this stream
and two supplied key-value pairs. |
EntryStream<K,V> |
append(K k1,
V v1,
K k2,
V v2,
K k3,
V v3)
Returns a new
EntryStream which is a concatenation of this stream
and three supplied key-value pairs. |
EntryStream<K,V> |
append(Map<K,V> map)
Returns a new
EntryStream which is a concatenation of this stream
and the stream created from the supplied map entries. |
void |
close()
Closes this stream, causing all close handlers for this stream pipeline
to be called.
|
EntryStream<K,List<V>> |
collapseKeys()
Merge series of adjacent stream entries with equal keys grouping the
corresponding values into
List. |
EntryStream<K,V> |
collapseKeys(BinaryOperator<V> merger)
Merge series of adjacent stream entries with equal keys combining the
corresponding values using the provided function.
|
<A,R> EntryStream<K,R> |
collapseKeys(Collector<? super V,A,R> collector)
Merge series of adjacent stream entries with equal keys combining the
corresponding values using the provided
Collector. |
EntryStream<K,V> |
distinctKeys()
Returns a stream consisting of the elements of this stream which have
distinct keys (according to object equality).
|
EntryStream<K,V> |
distinctValues()
Returns a stream consisting of the elements of this stream which have
distinct values (according to object equality).
|
static <K,V> EntryStream<K,V> |
empty()
Returns an empty sequential
EntryStream. |
EntryStream<K,V> |
filterKeys(Predicate<? super K> keyPredicate)
Returns a stream consisting of the elements of this stream which keys
match the given predicate.
|
EntryStream<K,V> |
filterKeyValue(BiPredicate<? super K,? super V> predicate)
Returns a stream consisting of the elements of this stream which elements
match the given predicate.
|
EntryStream<K,V> |
filterValues(Predicate<? super V> valuePredicate)
Returns a stream consisting of the elements of this stream which values
match the given predicate.
|
<KK> EntryStream<KK,V> |
flatMapKeys(Function<? super K,? extends Stream<? extends KK>> mapper)
Returns an
EntryStream consisting of the entries whose keys are
results of replacing source keys with the contents of a mapped stream
produced by applying the provided mapping function to each source key and
values are left intact. |
<R> StreamEx<R> |
flatMapKeyValue(BiFunction<? super K,? super V,? extends Stream<? extends R>> mapper)
Returns a stream consisting of the results of replacing each element of
this stream with the contents of a mapped stream produced by applying the
provided mapping function to each key-value pair.
|
<KK> EntryStream<KK,V> |
flatMapToKey(BiFunction<? super K,? super V,? extends Stream<? extends KK>> mapper)
Returns an
EntryStream consisting of the entries whose keys are
results of replacing source keys with the contents of a mapped stream
produced by applying the provided mapping function and values are left
intact. |
<VV> EntryStream<K,VV> |
flatMapToValue(BiFunction<? super K,? super V,? extends Stream<? extends VV>> mapper)
Returns an
EntryStream consisting of the entries whose values are
results of replacing source values with the contents of a mapped stream
produced by applying the provided mapping function and keys are left
intact. |
<VV> EntryStream<K,VV> |
flatMapValues(Function<? super V,? extends Stream<? extends VV>> mapper)
Returns an
EntryStream consisting of the entries whose values are
results of replacing source values with the contents of a mapped stream
produced by applying the provided mapping function to each source value
and keys are left intact. |
void |
forKeyValue(BiConsumer<? super K,? super V> action)
Performs an action for each key-value pair of this stream.
|
Map<K,List<V>> |
grouping()
Returns a
Map where elements of this stream with the same key are
grouped together. |
<A,D> Map<K,D> |
grouping(Collector<? super V,A,D> downstream)
Returns a
Map where elements of this stream with the same key are
grouped together. |
<M extends Map<K,List<V>>> |
grouping(Supplier<M> mapSupplier)
Returns a
Map where elements of this stream with the same key are
grouped together. |
<A,D,M extends Map<K,D>> |
grouping(Supplier<M> mapSupplier,
Collector<? super V,A,D> downstream)
Returns a
Map where elements of this stream with the same key are
grouped together. |
<C extends Collection<V>> |
groupingTo(Supplier<C> collectionFactory)
Returns a
Map where elements of this stream with the same key are
grouped together. |
<C extends Collection<V>,M extends Map<K,C>> |
groupingTo(Supplier<M> mapSupplier,
Supplier<C> collectionFactory)
Returns a
Map where elements of this stream with the same key are
grouped together. |
<M extends Map<K,V>> |
into(M map)
Drains the stream content into the supplied
Map. |
EntryStream<V,K> |
invert()
Returns a stream consisting of the
Map.Entry objects which keys are
the values of this stream elements and vice versa. |
boolean |
isParallel()
Returns whether this stream, if a terminal operation were to be executed,
would execute in parallel.
|
StreamEx<String> |
join(CharSequence delimiter)
Returns a
StreamEx of strings which are created joining the keys
and values of the current stream using the specified delimiter. |
StreamEx<String> |
join(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix)
Returns a
StreamEx of strings which are created joining the keys
and values of the current stream using the specified delimiter, with the
specified prefix and suffix. |
StreamEx<K> |
keys()
Returns a stream consisting of the keys of this stream elements.
|
<KK> EntryStream<KK,V> |
mapKeys(Function<? super K,? extends KK> keyMapper)
Returns an
EntryStream consisting of the entries whose keys are
modified by applying the given function and values are left unchanged. |
<R> StreamEx<R> |
mapKeyValue(BiFunction<? super K,? super V,? extends R> mapper)
Returns a
StreamEx consisting of the results of applying the
given function to the keys and values of this stream. |
<KK> EntryStream<KK,V> |
mapToKey(BiFunction<? super K,? super V,? extends KK> keyMapper)
Returns an
EntryStream consisting of the entries whose keys are
modified by applying the given function and values are left unchanged. |
<VV> EntryStream<K,VV> |
mapToValue(BiFunction<? super K,? super V,? extends VV> valueMapper)
Returns an
EntryStream consisting of the entries whose keys are
left unchanged and values are modified by applying the given function. |
<VV> EntryStream<K,VV> |
mapValues(Function<? super V,? extends VV> valueMapper)
Returns an
EntryStream consisting of the entries whose keys are
left unchanged and values are modified by applying the given function. |
EntryStream<K,V> |
nonNullKeys()
Returns a stream consisting of the elements of this stream which key is
not null.
|
EntryStream<K,V> |
nonNullValues()
Returns a stream consisting of the elements of this stream which value is
not null.
|
static <K,V> EntryStream<K,V> |
of(Iterator<? extends Map.Entry<K,V>> iterator)
Returns a sequential, ordered
EntryStream created from given
Iterator. |
static <K,V> EntryStream<K,V> |
of(K key,
V value)
Returns a sequential
EntryStream containing a single key-value
pair |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2)
Returns a sequential
EntryStream containing two key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3)
Returns a sequential
EntryStream containing three key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4)
Returns a sequential
EntryStream containing four key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5)
Returns a sequential
EntryStream containing five key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6)
Returns a sequential
EntryStream containing six key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7)
Returns a sequential
EntryStream containing seven key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8)
Returns a sequential
EntryStream containing eight key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8,
K k9,
V v9)
Returns a sequential
EntryStream containing nine key-value pairs |
static <K,V> EntryStream<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8,
K k9,
V v9,
K k10,
V v10)
Returns a sequential
EntryStream containing ten key-value pairs |
static <V> EntryStream<Integer,V> |
of(List<V> list)
Returns an
EntryStream object whose keys are indices of given
list and the values are the corresponding list elements. |
static <K,V> EntryStream<K,V> |
of(Map<K,V> map)
Returns an
EntryStream object which contains the entries of
supplied Map. |
static <K,V> EntryStream<K,V> |
of(Spliterator<? extends Map.Entry<K,V>> spliterator)
Returns a sequential
EntryStream created from given
Spliterator. |
static <K,V> EntryStream<K,V> |
of(Stream<? extends Map.Entry<K,V>> stream)
|
static <V> EntryStream<Integer,V> |
of(V[] array)
Returns an
EntryStream object whose keys are indices of given
array and the values are the corresponding array elements. |
static <T> EntryStream<T,T> |
ofPairs(List<T> list)
Returns a sequential ordered
EntryStream containing the possible
pairs of elements taken from the provided list. |
static <T> EntryStream<T,T> |
ofPairs(T[] array)
Returns a sequential ordered
EntryStream containing the possible
pairs of elements taken from the provided array. |
static <T> EntryStream<Integer,T> |
ofTree(T root,
BiFunction<Integer,T,Stream<T>> mapper)
Return a new
EntryStream containing all the nodes of tree-like
data structure in entry values along with the corresponding tree depths
in entry keys, in depth-first order. |
static <T,TT extends T> |
ofTree(T root,
Class<TT> collectionClass,
BiFunction<Integer,TT,Stream<T>> mapper)
Return a new
EntryStream containing all the nodes of tree-like
data structure in entry values along with the corresponding tree depths
in entry keys, in depth-first order. |
EntryStream<K,V> |
peekKeys(Consumer<? super K> keyAction)
Returns a stream consisting of the entries of this stream, additionally
performing the provided action on each entry key as entries are consumed
from the resulting stream.
|
EntryStream<K,V> |
peekKeyValue(BiConsumer<? super K,? super V> action)
Returns a stream consisting of the entries of this stream, additionally
performing the provided action on each entry key-value pair as entries
are consumed from the resulting stream.
|
EntryStream<K,V> |
peekValues(Consumer<? super V> valueAction)
Returns a stream consisting of the entries of this stream, additionally
performing the provided action on each entry value as entries are
consumed from the resulting stream.
|
EntryStream<K,V> |
prefixKeys(BinaryOperator<K> op)
Returns a new
EntryStream which values are the same as this
stream values and keys are the results of applying the accumulation
function to this stream keys, going left to right. |
EntryStream<K,V> |
prefixValues(BinaryOperator<V> op)
Returns a new
EntryStream which keys are the same as this stream
keys and values are the results of applying the accumulation function to
this stream values, going left to right. |
EntryStream<K,V> |
prepend(K key,
V value)
Returns a new
EntryStream which is a concatenation of the
supplied key-value pair and this stream. |
EntryStream<K,V> |
prepend(K k1,
V v1,
K k2,
V v2)
Returns a new
EntryStream which is a concatenation of two
supplied key-value pairs and this stream. |
EntryStream<K,V> |
prepend(K k1,
V v1,
K k2,
V v2,
K k3,
V v3)
Returns a new
EntryStream which is a concatenation of three
supplied key-value pairs and this stream. |
EntryStream<K,V> |
prepend(Map<K,V> map)
Returns a new
EntryStream which is a concatenation of the stream
created from the supplied map entries and this stream. |
EntryStream<K,V> |
removeKeys(Predicate<? super K> keyPredicate)
Returns a stream consisting of the elements of this stream which keys
don't match the given predicate.
|
EntryStream<K,V> |
removeKeyValue(BiPredicate<? super K,? super V> predicate)
Returns a stream consisting of the elements of this stream which values
don't match the given predicate.
|
EntryStream<K,V> |
removeValues(Predicate<? super V> valuePredicate)
Returns a stream consisting of the elements of this stream which values
don't match the given predicate.
|
<KK> EntryStream<KK,V> |
selectKeys(Class<KK> clazz)
Returns a stream consisting of the elements of this stream which keys are
instances of given class.
|
<VV> EntryStream<K,VV> |
selectValues(Class<VV> clazz)
Returns a stream consisting of the elements of this stream which values
are instances of given class.
|
Spliterator<Map.Entry<K, V>> |
spliterator()
Returns a spliterator for the elements of this stream.
|
<M extends Map<K,V>> |
toCustomMap(BinaryOperator<V> mergeFunction,
Supplier<M> mapSupplier)
Returns a
Map containing the elements of this stream. |
<M extends Map<K,V>> |
toCustomMap(Supplier<M> mapSupplier)
Returns a
Map containing the elements of this stream. |
Map<K,V> |
toImmutableMap()
Returns an immutable
Map containing the elements of this stream. |
Map<K,V> |
toMap()
Returns a
Map containing the elements of this stream. |
Map<K,V> |
toMap(BinaryOperator<V> mergeFunction)
Returns a
Map containing the elements of this stream. |
<R> R |
toMapAndThen(Function<? super Map<K,V>,R> finisher)
Creates a
Map containing the elements of this stream, then
performs finishing transformation and returns its result. |
NavigableMap<K,V> |
toNavigableMap()
Returns a
NavigableMap containing the elements of this stream. |
NavigableMap<K,V> |
toNavigableMap(BinaryOperator<V> mergeFunction)
Returns a
NavigableMap containing the elements of this stream. |
SortedMap<K,V> |
toSortedMap()
Returns a
SortedMap containing the elements of this stream. |
SortedMap<K,V> |
toSortedMap(BinaryOperator<V> mergeFunction)
Returns a
SortedMap containing the elements of this stream. |
StreamEx<V> |
values()
Returns a stream consisting of the values of this stream elements.
|
static <K,V> EntryStream<K,V> |
zip(K[] keys,
V[] values)
Returns a sequential
EntryStream containing Entry objects
composed from corresponding key and value in given two arrays. |
static <K,V> EntryStream<K,V> |
zip(List<K> keys,
List<V> values)
Returns a sequential
EntryStream containing Entry objects
composed from corresponding key and value in given two lists. |
allMatch, anyMatch, append, chain, collect, collect, count, distinct, distinct, dropWhile, filter, findAny, findAny, findFirst, findFirst, flatArray, flatCollection, flatMap, flatMapToDouble, flatMapToInt, flatMapToLong, foldLeft, foldLeft, foldRight, foldRight, forEach, forEachOrdered, indexOf, indexOf, iterator, limit, map, mapToDouble, mapToInt, mapToLong, max, maxBy, maxByDouble, maxByInt, maxByLong, min, minBy, minByDouble, minByInt, minByLong, noneMatch, nonNull, onClose, parallel, parallel, peek, prefix, prepend, reduce, reduce, reduce, remove, reverseSorted, scanLeft, scanLeft, scanRight, scanRight, sequential, skip, skipOrdered, sorted, sorted, sortedBy, sortedByDouble, sortedByInt, sortedByLong, takeWhile, takeWhileInclusive, toArray, toArray, toCollection, toImmutableList, toImmutableSet, toList, toListAndThen, toSet, toSetAndThen, unorderedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, isParallel, spliteratorspliteratorpublic StreamEx<String> join(CharSequence delimiter)
StreamEx of strings which are created joining the keys
and values of the current stream using the specified delimiter.
This is an intermediate operation.
delimiter - the delimiter to be used between key and valuepublic StreamEx<String> join(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
StreamEx of strings which are created joining the keys
and values of the current stream using the specified delimiter, with the
specified prefix and suffix.
This is an intermediate operation.
delimiter - the delimiter to be used between key and valueprefix - the sequence of characters to be used at the beginning of
each resulting stringsuffix - the sequence of characters to be used at the end of each
resulting stringpublic <KK> EntryStream<KK,V> flatMapKeys(Function<? super K,? extends Stream<? extends KK>> mapper)
EntryStream consisting of the entries whose keys are
results of replacing source keys with the contents of a mapped stream
produced by applying the provided mapping function to each source key and
values are left intact. Each mapped stream is
closed after its contents
have been placed into this stream. (If a mapped stream is null an
empty stream is used, instead.)
This is an intermediate operation.
KK - The type of new keysmapper - a non-interfering ,
stateless
function to apply to each key which produces a stream of new keyspublic <KK> EntryStream<KK,V> flatMapToKey(BiFunction<? super K,? super V,? extends Stream<? extends KK>> mapper)
EntryStream consisting of the entries whose keys are
results of replacing source keys with the contents of a mapped stream
produced by applying the provided mapping function and values are left
intact. Each mapped stream is closed after its contents have been placed into this stream. (If a
mapped stream is null an empty stream is used, instead.)
This is an intermediate operation.
KK - The type of new keysmapper - a non-interfering ,
stateless
function to apply to each key and value which produces a stream of
new keyspublic <VV> EntryStream<K,VV> flatMapValues(Function<? super V,? extends Stream<? extends VV>> mapper)
EntryStream consisting of the entries whose values are
results of replacing source values with the contents of a mapped stream
produced by applying the provided mapping function to each source value
and keys are left intact. Each mapped stream is
closed after its contents
have been placed into this stream. (If a mapped stream is null an
empty stream is used, instead.)
This is an intermediate operation.
VV - The type of new valuesmapper - a non-interfering ,
stateless
function to apply to each value which produces a stream of new
valuespublic <VV> EntryStream<K,VV> flatMapToValue(BiFunction<? super K,? super V,? extends Stream<? extends VV>> mapper)
EntryStream consisting of the entries whose values are
results of replacing source values with the contents of a mapped stream
produced by applying the provided mapping function and keys are left
intact. Each mapped stream is closed after its contents have been placed into this stream. (If a
mapped stream is null an empty stream is used, instead.)
This is an intermediate operation.
VV - The type of new valuesmapper - a non-interfering ,
stateless
function to apply to each key and value which produces a stream of
new valuespublic <R> StreamEx<R> flatMapKeyValue(BiFunction<? super K,? super V,? extends Stream<? extends R>> mapper)
null an empty stream is used, instead.)
This is an intermediate operation.
R - The element type of the new streammapper - a non-interfering, stateless function to apply to each
key-value pair which produces a stream of new valuespublic EntryStream<K,V> append(Map<K,V> map)
EntryStream which is a concatenation of this stream
and the stream created from the supplied map entries.
This is a quasi-intermediate operation.
May return this if the supplied map is empty and non-concurrent.
map - the map to prepend to the streampublic EntryStream<K,V> append(K key, V value)
EntryStream which is a concatenation of this stream
and the supplied key-value pair.
This is a quasi-intermediate operation.
key - the key of the new Entry to append to this streamvalue - the value of the new Entry to append to this streampublic EntryStream<K,V> append(K k1, V v1, K k2, V v2)
EntryStream which is a concatenation of this stream
and two supplied key-value pairs.
This is a quasi-intermediate operation.
k1 - the key of the first Entry to append to this streamv1 - the value of the first Entry to append to this streamk2 - the key of the second Entry to append to this streamv2 - the value of the second Entry to append to this streampublic EntryStream<K,V> append(K k1, V v1, K k2, V v2, K k3, V v3)
EntryStream which is a concatenation of this stream
and three supplied key-value pairs.
This is a quasi-intermediate operation.
k1 - the key of the first Entry to append to this streamv1 - the value of the first Entry to append to this streamk2 - the key of the second Entry to append to this streamv2 - the value of the second Entry to append to this streamk3 - the key of the third Entry to append to this streamv3 - the value of the third Entry to append to this streampublic EntryStream<K,V> prepend(Map<K,V> map)
EntryStream which is a concatenation of the stream
created from the supplied map entries and this stream.
This is a quasi-intermediate operation with tail-stream optimization.
May return this if the supplied map is empty and non-concurrent.
map - the map to prepend to the streampublic EntryStream<K,V> prepend(K key, V value)
EntryStream which is a concatenation of the
supplied key-value pair and this stream.
This is a quasi-intermediate operation with tail-stream optimization.
key - the key of the new Entry to prepend to this streamvalue - the value of the new Entry to prepend to this streampublic EntryStream<K,V> prepend(K k1, V v1, K k2, V v2)
EntryStream which is a concatenation of two
supplied key-value pairs and this stream.
This is a quasi-intermediate operation with tail-stream optimization.
k1 - the key of the first Entry to prepend to this streamv1 - the value of the first Entry to prepend to this streamk2 - the key of the second Entry to prepend to this streamv2 - the value of the second Entry to prepend to this streampublic EntryStream<K,V> prepend(K k1, V v1, K k2, V v2, K k3, V v3)
EntryStream which is a concatenation of three
supplied key-value pairs and this stream.
This is a quasi-intermediate operation with tail-stream optimization.
k1 - the key of the first Entry to prepend to this streamv1 - the value of the first Entry to prepend to this streamk2 - the key of the second Entry to prepend to this streamv2 - the value of the second Entry to prepend to this streamk3 - the key of the third Entry to prepend to this streamv3 - the value of the third Entry to prepend to this streampublic EntryStream<K,V> distinctKeys()
For ordered streams, the selection of distinct keys is stable (for elements with duplicating keys, the element appearing first in the encounter order is preserved.) For unordered streams, no stability guarantees are made.
This is a stateful intermediate operation.
public EntryStream<K,V> distinctValues()
For ordered streams, the selection of distinct values is stable (for elements with duplicating values, the element appearing first in the encounter order is preserved.) For unordered streams, no stability guarantees are made.
This is a stateful intermediate operation.
public <KK> EntryStream<KK,V> mapKeys(Function<? super K,? extends KK> keyMapper)
EntryStream consisting of the entries whose keys are
modified by applying the given function and values are left unchanged.
This is an intermediate operation.
KK - The type of the keys of the new streamkeyMapper - a non-interfering, stateless function to apply to each
keypublic <VV> EntryStream<K,VV> mapValues(Function<? super V,? extends VV> valueMapper)
EntryStream consisting of the entries whose keys are
left unchanged and values are modified by applying the given function.
This is an intermediate operation.
VV - The type of the values of the new streamvalueMapper - a non-interfering, stateless function to apply to each
valuepublic <R> StreamEx<R> mapKeyValue(BiFunction<? super K,? super V,? extends R> mapper)
StreamEx consisting of the results of applying the
given function to the keys and values of this stream.
This is an intermediate operation.
R - The element type of the new streammapper - a non-interfering, stateless function to apply to key and
value of each Map.Entry in this streampublic <KK> EntryStream<KK,V> mapToKey(BiFunction<? super K,? super V,? extends KK> keyMapper)
EntryStream consisting of the entries whose keys are
modified by applying the given function and values are left unchanged.
This is an intermediate operation.
KK - The type of the keys of the new streamkeyMapper - a non-interfering, stateless function to apply to each
key-value pair which returns the updated keypublic <VV> EntryStream<K,VV> mapToValue(BiFunction<? super K,? super V,? extends VV> valueMapper)
EntryStream consisting of the entries whose keys are
left unchanged and values are modified by applying the given function.
This is an intermediate operation.
VV - The type of the values of the new streamvalueMapper - a non-interfering, stateless function to apply to each
key-value pair which returns the updated valuepublic EntryStream<V,K> invert()
Map.Entry objects which keys are
the values of this stream elements and vice versa.
This is an intermediate operation.
public EntryStream<K,V> filterKeys(Predicate<? super K> keyPredicate)
This is an intermediate operation.
keyPredicate - a non-interfering, stateless predicate to apply to
the key of each element to determine if it should be includedpublic EntryStream<K,V> filterValues(Predicate<? super V> valuePredicate)
This is an intermediate operation.
valuePredicate - a non-interfering, stateless predicate to apply to
the value of each element to determine if it should be includedpublic EntryStream<K,V> filterKeyValue(BiPredicate<? super K,? super V> predicate)
This is an intermediate operation.
predicate - a non-interfering, stateless predicate to apply to the
key-value pairs of each element to determine if it should be
includedpublic EntryStream<K,V> removeKeys(Predicate<? super K> keyPredicate)
This is an intermediate operation.
keyPredicate - a non-interfering, stateless predicate to apply to
the key of each element to determine if it should be excludedpublic EntryStream<K,V> removeValues(Predicate<? super V> valuePredicate)
This is an intermediate operation.
valuePredicate - a non-interfering, stateless predicate to apply to
the value of each element to determine if it should be excludedpublic EntryStream<K,V> removeKeyValue(BiPredicate<? super K,? super V> predicate)
This is an intermediate operation.
predicate - a non-interfering, stateless predicate to apply to the
key-value pairs of each element to determine if it should be
excludedpublic EntryStream<K,V> nonNullKeys()
This is an intermediate operation.
public EntryStream<K,V> nonNullValues()
This is an intermediate operation.
public <KK> EntryStream<KK,V> selectKeys(Class<KK> clazz)
This is an intermediate operation.
KK - a type of keys to select.clazz - a class to filter the keys.public <VV> EntryStream<K,VV> selectValues(Class<VV> clazz)
This is an intermediate operation.
VV - a type of values to select.clazz - a class to filter the values.public EntryStream<K,V> peekKeys(Consumer<? super K> keyAction)
This is an intermediate operation.
For parallel stream pipelines, the action may be called at whatever time and in whatever thread the element is made available by the upstream operation. If the action modifies shared state, it is responsible for providing the required synchronization.
keyAction - a non-interfering action to perform on the keys of the
entries as they are consumed from the streampublic EntryStream<K,V> peekValues(Consumer<? super V> valueAction)
This is an intermediate operation.
For parallel stream pipelines, the action may be called at whatever time and in whatever thread the element is made available by the upstream operation. If the action modifies shared state, it is responsible for providing the required synchronization.
valueAction - a non-interfering action to perform on the values of
the entries as they are consumed from the streampublic EntryStream<K,V> peekKeyValue(BiConsumer<? super K,? super V> action)
This is an intermediate operation.
For parallel stream pipelines, the action may be called at whatever time and in whatever thread the element is made available by the upstream operation. If the action modifies shared state, it is responsible for providing the required synchronization.
action - a non-interfering action to perform on the keys and values
of the entries as they are consumed from the streampublic StreamEx<K> keys()
This is an intermediate operation.
public StreamEx<V> values()
This is an intermediate operation.
public EntryStream<K,List<V>> collapseKeys()
List.
This is a quasi-intermediate partial reduction operation.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the List objects of the resulting stream.
The key of the resulting entry is the key of the first merged entry.
EntryStream which keys are the keys of the original
stream and the values of adjacent entries with the same keys are
grouped into ListStreamEx.groupRuns(BiPredicate)public EntryStream<K,V> collapseKeys(BinaryOperator<V> merger)
This is a quasi-intermediate partial reduction operation.
The key of the resulting entry is the key of the first merged entry.
merger - a non-interfering, stateless, associative function to merge
values of two adjacent entries which keys are equal. Note that it
can be applied to the results if previous merges.EntryStream which keys are the keys of the original
stream and the values are values of the adjacent entries with the
same keys, combined using the provided merger function.StreamEx.collapse(BiPredicate, BinaryOperator)public <A,R> EntryStream<K,R> collapseKeys(Collector<? super V,A,R> collector)
Collector.
This is a quasi-intermediate partial reduction operation.
The key of the resulting entry is the key of the first merged entry.
R - the type of the values in the resulting streamA - the intermediate accumulation type of the Collectorcollector - a Collector which is used to combine the values
of the adjacent entries with the equal keys.EntryStream which keys are the keys of the original
stream and the values are values of the adjacent entries with the
same keys, combined using the provided collector.StreamEx.collapse(BiPredicate, Collector)public EntryStream<K,V> prefixKeys(BinaryOperator<K> op)
EntryStream which values are the same as this
stream values and keys are the results of applying the accumulation
function to this stream keys, going left to right.
This is a stateful quasi-intermediate operation.
This method cannot take all the advantages of parallel streams as it must
process elements strictly left to right. Using an unordered source or
removing the ordering constraint with AbstractStreamEx.unordered() may improve
the parallel processing speed.
op - an associative
, non-interfering
, stateless
function for computing the next key based on the previous oneAbstractStreamEx.prefix(BinaryOperator),
prefixValues(BinaryOperator)public EntryStream<K,V> prefixValues(BinaryOperator<V> op)
EntryStream which keys are the same as this stream
keys and values are the results of applying the accumulation function to
this stream values, going left to right.
This is a stateful quasi-intermediate operation.
This method cannot take all the advantages of parallel streams as it must
process elements strictly left to right. Using an unordered source or
removing the ordering constraint with AbstractStreamEx.unordered() may improve
the parallel processing speed.
op - an associative
, non-interfering
, stateless
function for computing the next value based on the previous oneAbstractStreamEx.prefix(BinaryOperator),
prefixKeys(BinaryOperator)public Map<K,V> toMap()
Map containing the elements of this stream. There are
no guarantees on the type or serializability of the Map returned;
if more control over the returned Map is required, use
toCustomMap(Supplier).
This is a terminal operation.
Returned Map is guaranteed to be modifiable.
For parallel stream the concurrent Map is created.
Map containing the elements of this streamIllegalStateException - if this stream contains duplicate keys
(according to Object.equals(Object))Collectors.toMap(Function, Function),
Collectors.toConcurrentMap(Function, Function),
toImmutableMap()public Map<K,V> toImmutableMap()
Map containing the elements of this stream.
There's no guarantees on exact type of the returned Map. In
particular, no specific element order in the resulting Map is
guaranteed. The returned Map is guaranteed to be serializable if
all its elements are serializable.
This is a terminal operation.
Map containing the elements of this streamIllegalStateException - if this stream contains duplicate keys
(according to Object.equals(Object))toMap()public <R> R toMapAndThen(Function<? super Map<K,V>,R> finisher)
Map containing the elements of this stream, then
performs finishing transformation and returns its result. There are no
guarantees on the type or serializability of the Map created.
This is a terminal operation.
Created Map is guaranteed to be modifiable.
For parallel stream the concurrent Map is created.
R - the type of the resultfinisher - a function to be applied to the intermediate mapMap
of the stream elements.IllegalStateException - if this stream contains duplicate keys
(according to Object.equals(Object))toMap()public Map<K,V> toMap(BinaryOperator<V> mergeFunction)
Map containing the elements of this stream. There are
no guarantees on the type or serializability of the Map returned;
if more control over the returned Map is required, use
toCustomMap(BinaryOperator, Supplier).
If the mapped keys contains duplicates (according to
Object.equals(Object)), the value mapping function is applied to
each equal element, and the results are merged using the provided merging
function.
This is a terminal operation.
Returned Map is guaranteed to be modifiable.
mergeFunction - a merge function, used to resolve collisions between
values associated with the same key, as supplied to
Map.merge(Object, Object, BiFunction)Map containing the elements of this streamCollectors.toMap(Function, Function),
Collectors.toConcurrentMap(Function, Function)public <M extends Map<K,V>> M toCustomMap(Supplier<M> mapSupplier)
Map containing the elements of this stream. The
Map is created by a provided supplier function.
This is a terminal operation.
M - the type of the resulting mapmapSupplier - a function which returns a new, empty Map into
which the results will be insertedMap containing the elements of this streamIllegalStateException - if this stream contains duplicate keys
(according to Object.equals(Object))Collectors.toMap(Function, Function),
Collectors.toConcurrentMap(Function, Function)public <M extends Map<K,V>> M toCustomMap(BinaryOperator<V> mergeFunction, Supplier<M> mapSupplier)
Map containing the elements of this stream. The
Map is created by a provided supplier function.
If the mapped keys contains duplicates (according to
Object.equals(Object)), the value mapping function is applied to
each equal element, and the results are merged using the provided merging
function.
This is a terminal operation.
M - the type of the resulting mapmergeFunction - a merge function, used to resolve collisions between
values associated with the same key.mapSupplier - a function which returns a new, empty Map into
which the results will be insertedMap containing the elements of this streamCollectors.toMap(Function, Function),
Collectors.toConcurrentMap(Function, Function)public SortedMap<K,V> toSortedMap()
SortedMap containing the elements of this stream. There
are no guarantees on the type or serializability of the SortedMap
returned; if more control over the returned Map is required, use
toCustomMap(Supplier).
This is a terminal operation.
Returned SortedMap is guaranteed to be modifiable.
For parallel stream the concurrent SortedMap is created.
SortedMap containing the elements of this streamIllegalStateException - if this stream contains duplicate keys
(according to Object.equals(Object))toNavigableMap()public SortedMap<K,V> toSortedMap(BinaryOperator<V> mergeFunction)
SortedMap containing the elements of this stream. There
are no guarantees on the type or serializability of the SortedMap
returned; if more control over the returned Map is required, use
toCustomMap(BinaryOperator, Supplier).
If the mapped keys contains duplicates (according to
Object.equals(Object)), the value mapping function is applied to
each equal element, and the results are merged using the provided merging
function.
This is a terminal operation.
Returned SortedMap is guaranteed to be modifiable.
mergeFunction - a merge function, used to resolve collisions between
values associated with the same key, as supplied to
Map.merge(Object, Object, BiFunction)SortedMap containing the elements of this streamtoNavigableMap(BinaryOperator)public NavigableMap<K,V> toNavigableMap()
NavigableMap containing the elements of this stream.
There are no guarantees on the type or serializability of the
NavigableMap returned; if more control over the returned
Map is required, use toCustomMap(Supplier).
This is a terminal operation.
Returned NavigableMap is guaranteed to be modifiable.
For parallel stream the concurrent NavigableMap is created.
NavigableMap containing the elements of this streamIllegalStateException - if this stream contains duplicate keys
(according to Object.equals(Object))Collectors.toMap(Function, Function),
Collectors.toConcurrentMap(Function, Function)public NavigableMap<K,V> toNavigableMap(BinaryOperator<V> mergeFunction)
NavigableMap containing the elements of this stream.
There are no guarantees on the type or serializability of the
NavigableMap returned; if more control over the returned
Map is required, use
toCustomMap(BinaryOperator, Supplier).
If the mapped keys contains duplicates (according to
Object.equals(Object)), the value mapping function is applied to
each equal element, and the results are merged using the provided merging
function.
This is a terminal operation.
Returned NavigableMap is guaranteed to be modifiable.
mergeFunction - a merge function, used to resolve collisions between
values associated with the same key, as supplied to
Map.merge(Object, Object, BiFunction)NavigableMap containing the elements of this streamCollectors.toMap(Function, Function)public <M extends Map<K,V>> M into(M map)
Map.
This is a terminal operation.
M - type of the resulting mapmap - a mutable map to put the stream elements intoIllegalStateException - if this stream contains duplicate keys, or
the stream contains the key which was already present in the map
(according to Object.equals(Object))public Map<K,List<V>> grouping()
Map where elements of this stream with the same key are
grouped together. The resulting Map keys are the keys of this
stream entries and the values are the lists of the corresponding values.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map or List objects returned. If
more control over the returned Map is required, use
grouping(Supplier). If more control over the lists required, use
groupingTo(Supplier).
This is a terminal operation.
Map containing the elements of this streamCollectors.groupingBy(Function)public <M extends Map<K,List<V>>> M grouping(Supplier<M> mapSupplier)
Map where elements of this stream with the same key are
grouped together. The resulting Map keys are the keys of this
stream entries and the values are the lists of the corresponding values.
The Map is created using the provided supplier function.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the List objects returned. If more control over
the lists required, use groupingTo(Supplier).
This is a terminal operation.
M - the type of the resulting MapmapSupplier - a function which returns a new, empty Map into
which the results will be insertedMap containing the elements of this streamgrouping(Supplier, Collector),
groupingTo(Supplier, Supplier)public <A,D> Map<K,D> grouping(Collector<? super V,A,D> downstream)
Map where elements of this stream with the same key are
grouped together. The resulting Map keys are the keys of this
stream entries and the corresponding values are combined using the
provided downstream collector.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map object returned. If more control over
the returned Map is required, use
grouping(Supplier, Collector).
This is a terminal operation.
A - the intermediate accumulation type of the downstream collectorD - the result type of the downstream reductiondownstream - a Collector implementing the downstream
reductionMap containing the elements of this streamCollectors.groupingBy(Function, Collector)public <A,D,M extends Map<K,D>> M grouping(Supplier<M> mapSupplier, Collector<? super V,A,D> downstream)
Map where elements of this stream with the same key are
grouped together. The resulting Map keys are the keys of this
stream entries and the corresponding values are combined using the
provided downstream collector. The Map is created using
the provided supplier function.
This is a terminal operation.
A - the intermediate accumulation type of the downstream collectorD - the result type of the downstream reductionM - the type of the resulting MapmapSupplier - a function which returns a new, empty Map into
which the results will be inserteddownstream - a Collector implementing the downstream
reductionMap containing the elements of this streamCollectors.groupingBy(Function, Supplier, Collector)public <C extends Collection<V>> Map<K,C> groupingTo(Supplier<C> collectionFactory)
Map where elements of this stream with the same key are
grouped together. The resulting Map keys are the keys of this
stream entries and the values are the collections of the corresponding
values. The collections are created by the provided factory.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map object returned. If more control over
the returned Map is required, use
groupingTo(Supplier, Supplier).
This is a terminal operation.
C - the type of the resulting CollectioncollectionFactory - a Supplier which returns a new, empty
Collection of the appropriate typeMap containing the elements of this streamCollectors.toCollection(Supplier)public <C extends Collection<V>,M extends Map<K,C>> M groupingTo(Supplier<M> mapSupplier, Supplier<C> collectionFactory)
Map where elements of this stream with the same key are
grouped together. The resulting Map keys are the keys of this
stream entries and the values are the collections of the corresponding
values. The collections are created by the provided factory.
This is a terminal operation.
C - the type of the resulting CollectionM - the type of the resulting MapmapSupplier - a function which returns a new, empty Map into
which the results will be insertedcollectionFactory - a Supplier which returns a new, empty
Collection of the appropriate typeMap containing the elements of this streamCollectors.toCollection(Supplier)public void forKeyValue(BiConsumer<? super K,? super V> action)
This is a terminal operation.
The behavior of this operation is explicitly nondeterministic. For parallel stream pipelines, this operation does not guarantee to respect the encounter order of the stream, as doing so would sacrifice the benefit of parallelism. For any given element, the action may be performed at whatever time and in whatever thread the library chooses. If the action accesses shared state, it is responsible for providing the required synchronization.
action - a non-interfering action to perform on the key and valueAbstractStreamEx.forEach(java.util.function.Consumer)public static <K,V> EntryStream<K,V> empty()
EntryStream.K - the type of stream element keysV - the type of stream element valuespublic static <K,V> EntryStream<K,V> of(Stream<? extends Map.Entry<K,V>> stream)
K - the type of original stream keysV - the type of original stream valuesstream - original streampublic static <K,V> EntryStream<K,V> of(Spliterator<? extends Map.Entry<K,V>> spliterator)
EntryStream created from given
Spliterator.K - the type of stream keysV - the type of stream valuesspliterator - a spliterator to create the stream from.public static <K,V> EntryStream<K,V> of(Iterator<? extends Map.Entry<K,V>> iterator)
EntryStream created from given
Iterator.
This method is roughly equivalent to
EntryStream.of(Spliterators.spliteratorUnknownSize(iterator, ORDERED))
, but may show better performance for parallel processing.
Use this method only if you cannot provide better Stream source (like
Collection or Spliterator).
K - the type of stream keysV - the type of stream valuesiterator - an iterator to create the stream from.public static <K,V> EntryStream<K,V> of(Map<K,V> map)
EntryStream object which contains the entries of
supplied Map.K - the type of map keysV - the type of map valuesmap - the map to create the stream fromEntryStreampublic static <V> EntryStream<Integer,V> of(List<V> list)
EntryStream object whose keys are indices of given
list and the values are the corresponding list elements.
The list elements are accessed using List.get(int), so the list
should provide fast random access. The list is assumed to be unmodifiable
during the stream operations.
V - list element typelist - list to create the stream fromEntryStreampublic static <V> EntryStream<Integer,V> of(V[] array)
EntryStream object whose keys are indices of given
array and the values are the corresponding array elements.V - array element typearray - array to create the stream fromEntryStreampublic static <K,V> EntryStream<K,V> of(K key, V value)
EntryStream containing a single key-value
pairK - the type of keyV - the type of valuekey - the key of the single elementvalue - the value of the single elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2)
EntryStream containing two key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3)
EntryStream containing three key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
EntryStream containing four key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
EntryStream containing five key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementk5 - the key of the fifth elementv5 - the value of the fifth elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
EntryStream containing six key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementk5 - the key of the fifth elementv5 - the value of the fifth elementk6 - the key of the sixth elementv6 - the value of the sixth elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)
EntryStream containing seven key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementk5 - the key of the fifth elementv5 - the value of the fifth elementk6 - the key of the sixth elementv6 - the value of the sixth elementk7 - the key of the seventh elementv7 - the value of the seventh elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8)
EntryStream containing eight key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementk5 - the key of the fifth elementv5 - the value of the fifth elementk6 - the key of the sixth elementv6 - the value of the sixth elementk7 - the key of the seventh elementv7 - the value of the seventh elementk8 - the key of the eighth elementv8 - the value of the eighth elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9)
EntryStream containing nine key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementk5 - the key of the fifth elementv5 - the value of the fifth elementk6 - the key of the sixth elementv6 - the value of the sixth elementk7 - the key of the seventh elementv7 - the value of the seventh elementk8 - the key of the eighth elementv8 - the value of the eighth elementk9 - the key of the ninth elementv9 - the value of the ninth elementpublic static <K,V> EntryStream<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10)
EntryStream containing ten key-value pairsK - the type of keyV - the type of valuek1 - the key of the first elementv1 - the value of the first elementk2 - the key of the second elementv2 - the value of the second elementk3 - the key of the third elementv3 - the value of the third elementk4 - the key of the fourth elementv4 - the value of the fourth elementk5 - the key of the fifth elementv5 - the value of the fifth elementk6 - the key of the sixth elementv6 - the value of the sixth elementk7 - the key of the seventh elementv7 - the value of the seventh elementk8 - the key of the eighth elementv8 - the value of the eighth elementk9 - the key of the ninth elementv9 - the value of the ninth elementk10 - the key of the tenth elementv10 - the value of the tenth elementpublic static <K,V> EntryStream<K,V> zip(List<K> keys, List<V> values)
EntryStream containing Entry objects
composed from corresponding key and value in given two lists.
The keys and values are accessed using List.get(int), so the
lists should provide fast random access. The lists are assumed to be
unmodifiable during the stream operations.
K - the type of stream element keysV - the type of stream element valueskeys - the list of keys, assumed to be unmodified during usevalues - the list of values, assumed to be unmodified during useEntryStreamIllegalArgumentException - if length of the lists differs.StreamEx.zip(List, List, BiFunction)public static <K,V> EntryStream<K,V> zip(K[] keys, V[] values)
EntryStream containing Entry objects
composed from corresponding key and value in given two arrays.K - the type of stream element keysV - the type of stream element valueskeys - the array of keysvalues - the array of valuesEntryStreamIllegalArgumentException - if length of the arrays differs.StreamEx.zip(Object[], Object[], BiFunction)public static <T> EntryStream<T,T> ofPairs(List<T> list)
EntryStream containing the possible
pairs of elements taken from the provided list.
Both keys and values are taken from the input list. The index of the key
is always strictly less than the index of the value. The pairs in the
stream are lexicographically ordered. For example, for the list of three
elements the stream of three elements is created:
Map.Entry(list.get(0), list.get(1)),
Map.Entry(list.get(0), list.get(2)) and
Map.Entry(list.get(1), list.get(2)). The number of elements in
the resulting stream is list.size()*(list.size()+1L)/2.
The list values are accessed using List.get(int), so the list
should provide fast random access. The list is assumed to be unmodifiable
during the stream operations.
T - type of the list elementslist - a list to take the elements fromEntryStreamStreamEx.ofPairs(List, BiFunction)public static <T> EntryStream<T,T> ofPairs(T[] array)
EntryStream containing the possible
pairs of elements taken from the provided array.
Both keys and values are taken from the input array. The index of the key
is always strictly less than the index of the value. The pairs in the
stream are lexicographically ordered. For example, for the array of three
elements the stream of three elements is created:
Map.Entry(array[0], array[1]),
Map.Entry(array[0], array[2]) and
Map.Entry(array[1], array[2]). The number of elements in the
resulting stream is array.length*(array.length+1L)/2..
T - type of the array elementsarray - a array to take the elements fromEntryStreamStreamEx.ofPairs(Object[], BiFunction)public static <T> EntryStream<Integer,T> ofTree(T root, BiFunction<Integer,T,Stream<T>> mapper)
EntryStream containing all the nodes of tree-like
data structure in entry values along with the corresponding tree depths
in entry keys, in depth-first order.
The keys of the returned stream are non-negative integer numbers. 0 is used for the root node only, 1 is for root immediate children, 2 is for their children and so on.
The streams created by mapper may be automatically
closed after its contents
already consumed and unnecessary anymore. It's not guaranteed that all
created streams will be closed during the stream terminal operation. If
it's necessary to close all the created streams, call the close()
method of the resulting stream returned by ofTree().
T - the type of tree nodesroot - root node of the treemapper - a non-interfering, stateless function to apply to each tree
node and its depth which returns null for leaf nodes or stream of
direct children for non-leaf nodes.EntryStreamStreamEx.ofTree(Object, Function),
ofTree(Object, Class, BiFunction)public static <T,TT extends T> EntryStream<Integer,T> ofTree(T root, Class<TT> collectionClass, BiFunction<Integer,TT,Stream<T>> mapper)
EntryStream containing all the nodes of tree-like
data structure in entry values along with the corresponding tree depths
in entry keys, in depth-first order.
The keys of the returned stream are non-negative integer numbers. 0 is used for the root node only, 1 is for root immediate children, 2 is for their children and so on.
The streams created by mapper may be automatically
closed after its contents
already consumed and unnecessary anymore. It's not guaranteed that all
created streams will be closed during the stream terminal operation. If
it's necessary to close all the created streams, call the close()
method of the resulting stream returned by ofTree().
T - the base type of tree nodesTT - the sub-type of composite tree nodes which may have childrenroot - root node of the treecollectionClass - a class representing the composite tree nodemapper - a non-interfering, stateless function to apply to each
composite tree node and its depth which returns stream of direct
children. May return null if the given node has no children.StreamEx.ofTree(Object, Class, Function),
ofTree(Object, BiFunction)public Spliterator<Map.Entry<K, V>> spliterator()
java.util.stream.BaseStreamThis is a terminal operation.
spliterator in interface BaseStream<T,S extends BaseStream<T,S>>public boolean isParallel()
java.util.stream.BaseStreamisParallel in interface BaseStream<T,S extends BaseStream<T,S>>true if this stream would execute in parallel if executedpublic void close()
java.util.stream.BaseStreamclose in interface AutoCloseableclose in interface BaseStream<T,S extends BaseStream<T,S>>AutoCloseable.close()Copyright © 2017. All rights reserved.