Modifier and Type | Method and Description |
---|---|
static <X,Y> Iterator<Pair<X,Y>> |
combinations(Iterator<X> iterator,
Iterable<Y> other)
This function returns a new Iterator providing the elements of the Cartesian Product of the elements provided
by
iterator and the elements of the other . |
static <X,Y,Z> Iterator<Z> |
combinations(Iterator<X> iterator,
Iterable<Y> other,
Functions.Function2<? super X,? super Y,? extends Z> merger)
This function returns a new Iterator providing the elements of the Cartesian Product of the elements provided
by
iterator and the elements of the other . |
static <X,Y> Iterator<Pair<X,Y>> |
combinationsWhere(Iterator<X> iterator,
Iterable<Y> other,
BiPredicate<X,Y> where)
This function returns a new Iterator providing the elements of the Cartesian Product of the elements provided
by
iterator and the elements of the other . |
static <X,Y,Z> Iterator<Z> |
combinationsWhere(Iterator<X> iterator,
Iterable<Y> other,
BiPredicate<X,Y> where,
Functions.Function2<? super X,? super Y,? extends Z> merger)
This function returns a new Iterator providing the elements of the Cartesian Product of the elements provided
by
iterator and the elements of the other . |
static ClassGroupingList |
groupIntoListBy(Iterator<?> iterator,
Class<?> firstGroup,
Class<?> secondGroup,
Class<?>... additionalGroups)
Groups the elements in
iterator into lists by the classes given via parameters firstGroup , firstGroup , and additionalGroups . |
static ClassGroupingSet |
groupIntoSetBy(Iterator<?> iterator,
Class<?> firstGroup,
Class<?> secondGroup,
Class<?>... additionalGroups)
Groups the elements in
iterator into sets by the classes given via parameters firstGroup , firstGroup , and additionalGroups . |
static <X,T extends X> |
into(Iterator<T> iterator,
Collection<X>... targets)
This method will add the elements provided by
iterator to the all of the collection in targets
and then return all those collections in an array. |
static <X,T extends X> |
into(Iterator<T> iterator,
Collection<X> target)
This method will add the elements provided by
iterator to the target collection
and then return the target collection. |
static <T> PrimitiveIterator.OfDouble |
mapDouble(Iterator<T> iterator,
ToDoubleFunction<T> mapper)
This function maps an
Iterator to a PrimitiveIterator.OfDouble , using the
mapper function for each element of the original iterator . |
static <T> PrimitiveIterator.OfInt |
mapInt(Iterator<T> iterator,
ToIntFunction<T> mapper)
This function maps an
Iterator to a PrimitiveIterator.OfInt , using the
mapper function for each element of the original iterator . |
static <T> PrimitiveIterator.OfLong |
mapLong(Iterator<T> iterator,
ToLongFunction<T> mapper)
This function maps an
Iterator to a PrimitiveIterator.OfLong , using the
mapper function for each element of the original iterator . |
static <X,Y> Partition<List<Y>,List<X>> |
partitionBy(Iterator<X> iterator,
Class<Y> selectionClass)
This method partitions the elements in the given
iterator into elements instance of selectionClass
and elements that are not. |
static <X,Y,S,R> Partition<S,R> |
partitionBy(Iterator<X> iterator,
Class<Y> selectionClass,
Collector<Y,?,S> selectedCollector,
Collector<X,?,R> rejectedCollector)
This method partitions the elements provided by the
iterator into elements instance of selectionClass
and elements that are not. |
static <X> Partition<List<X>,List<X>> |
partitionBy(Iterator<X> iterator,
Predicate<X> partitionPredicate)
This method partitions the elements provided by the
iterator into elements for which partitionPredicate
evaluates to true and elements for which partitionPredicate evaluates to false . |
static <X,AS,AR> Partition<AS,AR> |
partitionBy(Iterator<X> iterator,
Predicate<X> partitionPredicate,
Collector<X,?,AS> selectedCollector,
Collector<X,?,AR> rejectedCollector)
This method partitions the elements provided by
iterator into aggregated elements for which partitionPredicate
evaluates to true and aggregated elements for which partitionPredicate evaluates to false . |
static <X,AX> Partition<AX,AX> |
partitionBy(Iterator<X> iterator,
Predicate<X> partitionPredicate,
Collector<X,?,AX> collector)
This method partitions the elements provided by
iterator into aggregated elements for which partitionPredicate
evaluates to true and aggregated elements for which partitionPredicate evaluates to false . |
static <T> Iterator<T> |
withoutAll(Iterator<T> iterator,
Iterable<?> toExclude)
Filters the given
iterator by filtering all elements out that are also included
in the given Iterable toExclude . |
public static <T> PrimitiveIterator.OfInt mapInt(Iterator<T> iterator, ToIntFunction<T> mapper)
Iterator
to a PrimitiveIterator.OfInt
, using the
mapper
function for each element of the original iterator
.
The returned PrimitiveIterator.OfInt
is lazy, only calling
the mapper
function when a next element is pulled from it.T
- type of elements in iterator
, that are mapped to int
s via mapper
.iterator
- the Iterator
of which each element should be mapped to int
values.mapper
- the mapping function, mapping each element of iterator
to an int
value.PrimitiveIterator.OfInt
mapped from the elements of the input iterator
.NullPointerException
- if iterator
or mapper
is null
public static <T> PrimitiveIterator.OfLong mapLong(Iterator<T> iterator, ToLongFunction<T> mapper)
Iterator
to a PrimitiveIterator.OfLong
, using the
mapper
function for each element of the original iterator
.
The returned PrimitiveIterator.OfLong
is lazy, only calling
the mapper
function when a next element is pulled from it.T
- type of elements in iterator
, that are mapped to long
s via mapper
.iterator
- the Iterator
of which each element should be mapped to long
values.mapper
- the mapping function, mapping each element of iterator
to an long
value.PrimitiveIterator.OfLong
mapped from the elements of the input iterator
.NullPointerException
- if iterator
or mapper
is null
public static <T> PrimitiveIterator.OfDouble mapDouble(Iterator<T> iterator, ToDoubleFunction<T> mapper)
Iterator
to a PrimitiveIterator.OfDouble
, using the
mapper
function for each element of the original iterator
.
The returned PrimitiveIterator.OfDouble
is lazy, only calling
the mapper
function when a next element is pulled from it.T
- type of elements in iterator
, that are mapped to double
s via mapper
.iterator
- the Iterator
of which each element should be mapped to double
values.mapper
- the mapping function, mapping each element of iterator
to an double
value.PrimitiveIterator.OfDouble
mapped from the elements of the input iterator
.NullPointerException
- if iterator
or mapper
is null
public static ClassGroupingSet groupIntoSetBy(Iterator<?> iterator, Class<?> firstGroup, Class<?> secondGroup, Class<?>... additionalGroups)
iterator
into sets by the classes given via parameters firstGroup
, firstGroup
, and additionalGroups
.
The elements will be checked to be instance of the given classes in the
order they appear in the parameter list. So if e.g. classes Object
and String
are passed into the function in this order, an instance of String
will land
in the group of Object
. Also note that objects that are not matching any given class
are simply omitted from the resulting grouping. If you need a group for all objects that
were not matched, just pass in the class of Object
as the last parameter.iterator
- the iterator, that provides the elements to be be grouped into sets by the given classesfirstGroup
- first class elements of iterator
are be grouped bysecondGroup
- first class elements of iterator
are be grouped byadditionalGroups
- further classes to group elements by. This parameter is allowed to be null
.firstGroup
, firstGroup
, and additionalGroups
.partitionBy(Iterator, Class)
,
partitionBy(Iterator, Class, Collector, Collector)
public static ClassGroupingList groupIntoListBy(Iterator<?> iterator, Class<?> firstGroup, Class<?> secondGroup, Class<?>... additionalGroups)
iterator
into lists by the classes given via parameters firstGroup
, firstGroup
, and additionalGroups
.
The elements will be checked to be instance of the given classes in the
order they appear in the parameter list. So if e.g. classes Object
and String
are passed into the function in this order, an instance of String
will land
in the group of Object
. Also note that objects that are not matching any given class
are simply omitted from the resulting grouping. If you need a group for all objects that
were not matched, just pass in the class of Object
as the last parameter.iterator
- the iterator, that provides the elements to be be grouped into sets by the given classesfirstGroup
- first class elements of iterator
are be grouped bysecondGroup
- first class elements of iterator
are be grouped byadditionalGroups
- further classes to group elements by. This parameter is allowed to be null
.firstGroup
, firstGroup
, and additionalGroups
.partitionBy(Iterator, Class)
,
partitionBy(Iterator, Class, Collector, Collector)
public static <T> Iterator<T> withoutAll(Iterator<T> iterator, Iterable<?> toExclude)
iterator
by filtering all elements out that are also included
in the given Iterable toExclude
. If an element from iterator
is null
it is removed
if toExclude
also contains a null
value. Otherwise elements e
from
iterator
are only removed, if toExclude
contains an element o
, where e.equals(o)
.T
- Type of elements provided by iterator
iterator
- the iterator to be filtered. Must not be null
.toExclude
- the elements not to be included in the resulting iterator. Must not be null
.iterator
not containing elements from toExclude
.NullPointerException
- will be thrown if iterator
or toExclude
is null
.public static <X,Y> Iterator<Pair<X,Y>> combinations(Iterator<X> iterator, Iterable<Y> other)
iterator
and the elements of the other
. The
combination of elements of the iterator
and the other
are represented
as Pair
s of the values from both sources.X
- Type of elements in iterator
.Y
- Type of elements provided by other
iterator
- the iterator that's elements are combined with every elements from other
. Must not be null
.other
- the elements to be combined with each element from iterator
. Must not be null
.iterator
with every element of the elements provided by other
.NullPointerException
- is thrown if iterator
or other
is null
public static <X,Y,Z> Iterator<Z> combinations(Iterator<X> iterator, Iterable<Y> other, Functions.Function2<? super X,? super Y,? extends Z> merger)
iterator
and the elements of the other
. The
combination of elements of the iterator
and the other
are computed using the merger
function.X
- Type of elements in iterator
.Y
- Type of elements provided by other
Z
- Type of the merged elementsiterator
- the iterator that's elements are combined with every elements from other
. Must not be null
.other
- the elements to be combined with each element from iterator
. Must not be null
.merger
- the function combining the elements from iterator
and other
.iterator
with every element of the elements provided by other
.NullPointerException
- is thrown if iterator
, or other
, or merger
is null
public static <X,Y> Iterator<Pair<X,Y>> combinationsWhere(Iterator<X> iterator, Iterable<Y> other, BiPredicate<X,Y> where)
iterator
and the elements of the other
. A combination of values from iterator
and
other
will only be included in the resulting iterator, if the where
predicate holds true for
the combination. The combination of elements are represented as Pair
s of the values from both sources.X
- Type of elements in iterator
.Y
- Type of elements provided by other
iterator
- the iterator that's elements are combined with every elements from other
. Must not be null
.other
- the elements to be combined with each element from iterator
. Must not be null
.where
- a filtering predicate to only produce combinations for which this predicate holds true. Must not be null
.iterator
with every element of the elements provided by other
for which the where
predicate holds true.NullPointerException
- is thrown if iterator
, or other
or where
is null
public static <X,Y,Z> Iterator<Z> combinationsWhere(Iterator<X> iterator, Iterable<Y> other, BiPredicate<X,Y> where, Functions.Function2<? super X,? super Y,? extends Z> merger)
iterator
and the elements of the other
. A combination of values from iterator
and
other
will only be included in the resulting iterator, if the where
predicate holds true for
the combination. The combination of elements of the iterator
and the other
are computed using
the merger
function.X
- Type of elements in iterator
.Y
- Type of elements provided by other
Z
- Type of the merged elementsiterator
- the iterator that's elements are combined with every elements from other
. Must not be null
.other
- the elements to be combined with each element from iterator
. Must not be null
.where
- a filtering predicate to only produce combinations for which this predicate holds true. Must not be null
.merger
- the function combining the elements from iterator
and other
.iterator
with every element of the elements provided by other
for which the where
predicate holds true. The elements are a result of the merger
call for each combinationNullPointerException
- is thrown if iterator
, or other
, or where
, or merger
is null
public static <X,Y> Partition<List<Y>,List<X>> partitionBy(Iterator<X> iterator, Class<Y> selectionClass)
iterator
into elements instance of selectionClass
and elements that are not. The returned partition holds the elements instance of selectionClass
in the selected partition and the other elements in the rejected partition. Partitions are Lists of the
elements. The relative order of the elements in iterator
is preserved in the respective partitions.
There is no guarantee about mutability or thread safety of the list partitions. If there is no element
selected or rejected, the respective parts will hold an empty List; the parts are guaranteed to be not null
.X
- Type of elements in iterator
Y
- Type of elements that are part of iterator
and will be put into the resulting selected partition.iterator
- source iterator, that's elements are partitioned based on selectionClass
selectionClass
- the class elements in iterator
are checked to be instance of. Elements
that are instance of selectionClass
will be added to the selected partition of the result.
Elements that are not, will end up in the rejected partition.iterator
, providing the selected elements, that are instance of selectionClass
, and rejected elements
not instance of selectionClass
.NullPointerException
- if iterator
or selectionClass
is null
groupIntoListBy(Iterator, Class, Class, Class[])
,
groupIntoSetBy(Iterator, Class, Class, Class[])
public static <X,Y,S,R> Partition<S,R> partitionBy(Iterator<X> iterator, Class<Y> selectionClass, Collector<Y,?,S> selectedCollector, Collector<X,?,R> rejectedCollector)
iterator
into elements instance of selectionClass
and elements that are not. Elements instance of selectionClass
are aggregated using the selectedCollector
and the result will be available via the selected part of the returned partition. Elements not instance of selectionClass
are aggregated using the rejectedCollector
and provided via the selected part of the returned partition.X
- Type of elements provided by iterator
Y
- Type of elements that are part of the iterator
and will be put into the resulting aggregation of the selected
part of the returned partition.S
- Aggregation result type of the selected part of the returned partition, created by selectedCollector
.R
- Aggregation result type of the rejected part of the returned partition, created by rejectedCollector
.iterator
- source iterator, that's elements are partitioned based on selectionClass
selectionClass
- the class elements provided by iterator
are checked to be instance of. Elements
that are instance of selectionClass
will be aggregated into the selected partition of the result.
Elements that are not, will end up in the aggregated rejected partition.selectedCollector
- aggregates all elements provided by iterator
that are instance of selectionClass
. The
aggregation result will be provided by the selected part of the returned partition.rejectedCollector
- aggregates all elements provided by iterator
that are not instance of selectionClass
. The
aggregation result will be provided by the rejected part of the returned partition.iterator
, providing the aggregation of selected elements, that are instance of selectionClass
,
and the aggregation of rejected elements not instance of selectionClass
.NullPointerException
- if iterator
, selectionClass
, selectedCollector
or rejectedCollector
is null
groupIntoListBy(Iterator, Class, Class,Class[])
,
groupIntoSetBy(Iterator, Class, Class,Class[])
public static <X> Partition<List<X>,List<X>> partitionBy(Iterator<X> iterator, Predicate<X> partitionPredicate)
iterator
into elements for which partitionPredicate
evaluates to true
and elements for which partitionPredicate
evaluates to false
.
The selected part of the returned partition holds the elements for which partitionPredicate
evaluates to true
, the rejected part contains the other elements from the iterator
.
Partition parts are Lists of the elements. The relative order of the elements provided by the iterator
is preserved
in the respective partitions. There is no guarantee about mutability or thread safety of the lists. If there is no element
selected or rejected, the respective parts will hold an empty List; the parts are guaranteed to be not null
.X
- Type of elements provided by iterator
iterator
- source iterator, that's elements are partitioned based on selectionClass
partitionPredicate
- predicate deciding if an element provided by iterator
will end up in the
selected or rejected part of the returned partition. Elements for which the test returns true
end up in the selected part, others land in the rejected part.iterator
, providing the selected elements, for which partitionPredicate
evaluates to true
and rejected elements for which partitionPredicate
evaluates to false
.NullPointerException
- if iterator
or partitionPredicate
is null
public static <X,AX> Partition<AX,AX> partitionBy(Iterator<X> iterator, Predicate<X> partitionPredicate, Collector<X,?,AX> collector)
iterator
into aggregated elements for which partitionPredicate
evaluates to true
and aggregated elements for which partitionPredicate
evaluates to false
.
The selected part of the returned partition holds the elements aggregated using the given collector
for which
partitionPredicate
evaluates to true
. The rejected part contains the other elements aggregated using the
given collector
from the iterator
.X
- Type of elements provided by iterator
AX
- Type of aggregated elements provided by the returned partitioniterator
- source iterator, that's provided elements are partitioned based on selectionClass
partitionPredicate
- predicate deciding if an element in iterator
will end up in the
selected or rejected part of the returned partition. Elements for which the test returns true
end up in the selected part, others land in the rejected part.collector
- used for aggregating the selected and rejected elements in the returned partition.iterator
, providing the selected elements, for which partitionPredicate
evaluates to true
aggregated using the given collector
and rejected elements for which partitionPredicate
evaluates to false
aggregated using the given collector
.NullPointerException
- if iterator
, collector
or partitionPredicate
is null
public static <X,AS,AR> Partition<AS,AR> partitionBy(Iterator<X> iterator, Predicate<X> partitionPredicate, Collector<X,?,AS> selectedCollector, Collector<X,?,AR> rejectedCollector)
iterator
into aggregated elements for which partitionPredicate
evaluates to true
and aggregated elements for which partitionPredicate
evaluates to false
.
The selected part of the returned partition holds the elements aggregated using the given selectedCollector
for which
partitionPredicate
evaluates to true
. The rejected part contains the other elements aggregated using the
given rejectedCollector
from iterator
.X
- Type of elements provided by iterator
AS
- Type of aggregated elements provided by the selected part of the returned partition.AR
- Type of aggregated elements provided by the rejected part of the returned partition.iterator
- source iterator, that's provided elements are partitioned based on selectionClass
partitionPredicate
- predicate deciding if an element provided by iterator
will end up aggregated in the
selected or aggregated in the rejected part of the returned partition. Elements for which the test returns true
end up in the aggregated selected part, others land in the aggregated rejected part.selectedCollector
- used for aggregating the selected elements in the returned partition.rejectedCollector
- used for aggregating the rejected elements in the returned partition.iterator
, providing the selected elements, for which partitionPredicate
evaluates to true
aggregated using the given collector
and rejected elements for which partitionPredicate
evaluates to false
aggregated using the given collector
.NullPointerException
- if iterator
, selectedCollector
, rejectedCollector
or partitionPredicate
is null
public static <X,T extends X> Collection<X> into(Iterator<T> iterator, Collection<X> target)
iterator
to the target
collection
and then return the target
collection. The elements will be added to target
in the order that is provided by the forEachRemaining
method defined on iterator
.target
collection will include the elements provided by
iterator
. This is intentional and is beneficial if the the elements need to be used
in subsequent statement after calling this method.
vararg overload
will
create may implicitly create an array instance. This is avoided with this
overload.X
- Type of elements of target
. Must be either T
or a super class of T
.T
- Type of elements provided by iterator
.iterator
- the source of elements to be added to target
. Must not be null
.target
- the collection to which the elements of iterator
are added to. This reference
will also be returned by this method. Must not be null
.target
reference. The elements taken from iterator
will have been added to it when
being returned.NullPointerException
- if iterator
, selectedCollector
, or target
is null
into(Iterator, Collection[])
public static <X,T extends X> Collection<X>[] into(Iterator<T> iterator, Collection<X>... targets)
iterator
to the all of the collection in targets
and then return all those collections in an array. The elements will be added to the targets
collections
in the order that is provided by the forEach
method defined on iterator
.targets
collections will include the elements provided by
iterator
. This is intentional and is beneficial if the the elements need to be used
in subsequent statement after calling this method.X
- Type of elements of collections in targets
. Must be either T
or a super class of T
.T
- Type of elements provided by iterator
.iterator
- the source of elements to be added to the collections in targets
. Must not be null
.targets
- the collections to which the elements of iterator
are added to. An array of the same collections
will also be returned by this method. Must not be null
and no contained collection reference must be null
.targets
. The elements from iterator
will have been added to each of the contained
collections when being returned.NullPointerException
- if iterator
, selectedCollector
, or targets
, or a
collection in targets
is null
.into(Iterator, Collection)
Copyright © 2019. All rights reserved.