Class IterableUtils
Iterable
instances.
Note: This utility class has been designed with fail-fast argument checking.
- All decorator methods are not null-safe for the provided Iterable argument; for example, they will throw a
NullPointerException
if a null Iterable is passed as argument. - All other utility methods are null-safe for the provided Iterable argument; for example, they will treat a null Iterable the same way as an empty one.
For other arguments which are null, a
Predicate
will result in aNullPointerException
. Exception: passing a nullComparator
is equivalent to a Comparator with natural ordering.
- Since:
- 4.1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> Iterable
<E> boundedIterable
(Iterable<E> iterable, long maxSize) Returns a view of the given iterable that contains at most the given number of elements.static <E> Iterable
<E> chainedIterable
(Iterable<? extends E>... iterables) Combines the provided iterables into a single iterable.static <E> Iterable
<E> chainedIterable
(Iterable<? extends E> a, Iterable<? extends E> b) Combines two iterables into a single iterable.static <E> Iterable
<E> chainedIterable
(Iterable<? extends E> a, Iterable<? extends E> b, Iterable<? extends E> c) Combines three iterables into a single iterable.static <E> Iterable
<E> chainedIterable
(Iterable<? extends E> a, Iterable<? extends E> b, Iterable<? extends E> c, Iterable<? extends E> d) Combines four iterables into a single iterable.static <E> Iterable
<E> collatedIterable
(Iterable<? extends E> a, Iterable<? extends E> b) Combines the two provided iterables into an ordered iterable using natural ordering.static <E> Iterable
<E> collatedIterable
(Comparator<? super E> comparator, Iterable<? extends E> a, Iterable<? extends E> b) Combines the two provided iterables into an ordered iterable using the provided comparator.static <E> boolean
Checks if the object is contained in the given iterable.static <E> boolean
Checks if the object is contained in the given iterable.static <E> long
countMatches
(Iterable<E> input, Predicate<? super E> predicate) Counts the number of elements in the input iterable that match the predicate.static <E> List
<E> duplicateList
(Iterable<E> iterable) Finds and returns the List of duplicate elements in the given collection.static <E> Set
<E> duplicateSequencedSet
(Iterable<E> iterable) Finds and returns the sequenced Set of duplicate elements in the given collection.static <E> Set
<E> duplicateSet
(Iterable<E> iterable) Finds and returns the set of duplicate elements in the given collection.static <E> Iterable
<E> emptyIfNull
(Iterable<E> iterable) Returns an immutable empty iterable if the argument is null, or the argument itself otherwise.static <E> Iterable
<E> Gets an empty iterable.static <E> Iterable
<E> filteredIterable
(Iterable<E> iterable, Predicate<? super E> predicate) Returns a view of the given iterable that only contains elements matching the provided predicate.static <E> E
Finds the first element in the given iterable which matches the given predicate.static <T> T
Shortcut forget(iterator, 0)
.static <E> void
Applies the closure to each element of the provided iterable.static <E> E
forEachButLast
(Iterable<E> iterable, Closure<? super E> closure) Executes the given closure on each but the last element in the iterable.static <E,
T extends E>
intReturns the number of occurrences of the provided object in the iterable.static <T> T
Returns theindex
-th value in theiterable
'sIterator
, throwingIndexOutOfBoundsException
if there is no such element.static <E> int
Returns the index of the first element in the specified iterable that matches the given predicate.static boolean
Answers true if the provided iterable is empty.static <E> Iterable
<E> loopingIterable
(Iterable<E> iterable) Returns a view of the given iterable which will cycle infinitely over its elements.static <E> boolean
matchesAll
(Iterable<E> iterable, Predicate<? super E> predicate) Answers true if a predicate is true for every element of an iterable.static <E> boolean
matchesAny
(Iterable<E> iterable, Predicate<? super E> predicate) Answers true if a predicate is true for any element of the iterable.static <O,
R extends Collection<O>>
List<R> partition
(Iterable<? extends O> iterable, Factory<R> partitionFactory, Predicate<? super O>... predicates) Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicates.Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicate.Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicates.static <E> Iterable
<E> reversedIterable
(Iterable<E> iterable) Returns a reversed view of the given iterable.static int
Returns the number of elements contained in the given iterator.static <E> Iterable
<E> skippingIterable
(Iterable<E> iterable, long elementsToSkip) Returns a view of the given iterable that skips the first N elements.static <E> List
<E> Gets a new list with the contents of the provided iterable.static <E> String
Returns a string representation of the elements of the specified iterable.static <E> String
toString
(Iterable<E> iterable, Transformer<? super E, String> transformer) Returns a string representation of the elements of the specified iterable.static <E> String
toString
(Iterable<E> iterable, Transformer<? super E, String> transformer, String delimiter, String prefix, String suffix) Returns a string representation of the elements of the specified iterable.static <I,
O> Iterable <O> transformedIterable
(Iterable<I> iterable, Transformer<? super I, ? extends O> transformer) Returns a transformed view of the given iterable where all of its elements have been transformed by the provided transformer.static <E> Iterable
<E> uniqueIterable
(Iterable<E> iterable) Returns a unique view of the given iterable.static <E> Iterable
<E> unmodifiableIterable
(Iterable<E> iterable) Returns an unmodifiable view of the given iterable.static <E> Iterable
<E> zippingIterable
(Iterable<? extends E> a, Iterable<? extends E> b) Interleaves two iterables into a single iterable.static <E> Iterable
<E> zippingIterable
(Iterable<? extends E> first, Iterable<? extends E>... others) Interleaves two iterables into a single iterable.
-
Constructor Details
-
IterableUtils
Deprecated.TODO Make private in 5.0.Make private in 5.0.
-
-
Method Details
-
boundedIterable
Returns a view of the given iterable that contains at most the given number of elements.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to limit, may not be nullmaxSize
- the maximum number of elements, must not be negative- Returns:
- a bounded view on the specified iterable
- Throws:
IllegalArgumentException
- if maxSize is negativeNullPointerException
- if iterable is null
-
chainedIterable
Combines the provided iterables into a single iterable.The returned iterable has an iterator that traverses the elements in the order of the arguments, i.e. iterables[0], iterables[1], .... The source iterators are not polled until necessary.
The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
iterables
- the iterables to combine, may not be null- Returns:
- a new iterable, combining the provided iterables
- Throws:
NullPointerException
- if either of the provided iterables is null
-
chainedIterable
Combines two iterables into a single iterable.The returned iterable has an iterator that traverses the elements in
a
, followed by the elements inb
. The source iterators are not polled until necessary.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
a
- the first iterable, may not be nullb
- the second iterable, may not be null- Returns:
- a new iterable, combining the provided iterables
- Throws:
NullPointerException
- if either a or b is null
-
chainedIterable
public static <E> Iterable<E> chainedIterable(Iterable<? extends E> a, Iterable<? extends E> b, Iterable<? extends E> c) Combines three iterables into a single iterable.The returned iterable has an iterator that traverses the elements in
a
, followed by the elements inb
andc
. The source iterators are not polled until necessary.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
a
- the first iterable, may not be nullb
- the second iterable, may not be nullc
- the third iterable, may not be null- Returns:
- a new iterable, combining the provided iterables
- Throws:
NullPointerException
- if either of the provided iterables is null
-
chainedIterable
public static <E> Iterable<E> chainedIterable(Iterable<? extends E> a, Iterable<? extends E> b, Iterable<? extends E> c, Iterable<? extends E> d) Combines four iterables into a single iterable.The returned iterable has an iterator that traverses the elements in
a
, followed by the elements inb
,c
andd
. The source iterators are not polled until necessary.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
a
- the first iterable, may not be nullb
- the second iterable, may not be nullc
- the third iterable, may not be nulld
- the fourth iterable, may not be null- Returns:
- a new iterable, combining the provided iterables
- Throws:
NullPointerException
- if either of the provided iterables is null
-
collatedIterable
public static <E> Iterable<E> collatedIterable(Comparator<? super E> comparator, Iterable<? extends E> a, Iterable<? extends E> b) Combines the two provided iterables into an ordered iterable using the provided comparator. If the comparator is null, natural ordering will be used.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
comparator
- the comparator defining an ordering over the elements, may be null, in which case natural ordering will be useda
- the first iterable, may not be nullb
- the second iterable, may not be null- Returns:
- a filtered view on the specified iterable
- Throws:
NullPointerException
- if either of the provided iterables is null
-
collatedIterable
Combines the two provided iterables into an ordered iterable using natural ordering.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
a
- the first iterable, must not be nullb
- the second iterable, must not be null- Returns:
- a filtered view on the specified iterable
- Throws:
NullPointerException
- if either of the provided iterables is null
-
contains
public static <E> boolean contains(Iterable<? extends E> iterable, E object, Equator<? super E> equator) Checks if the object is contained in the given iterable. Object equality is tested with anequator
unlikecontains(Iterable, Object)
which usesObject.equals(Object)
.A
null
or empty iterable returns false. Anull
object will not be passed to the equator, instead aNullPredicate
will be used.- Type Parameters:
E
- the type of object theIterable
contains- Parameters:
iterable
- the iterable to check, may be nullobject
- the object to checkequator
- the equator to use to check, may not be null- Returns:
- true if the object is contained in the iterable, false otherwise
- Throws:
NullPointerException
- if equator is null
-
contains
Checks if the object is contained in the given iterable.A
null
or empty iterable returns false.- Type Parameters:
E
- the type of object theIterable
contains- Parameters:
iterable
- the iterable to check, may be nullobject
- the object to check- Returns:
- true if the object is contained in the iterable, false otherwise
-
countMatches
Counts the number of elements in the input iterable that match the predicate.A
null
iterable matches no elements.- Type Parameters:
E
- the type of object theIterable
contains- Parameters:
input
- theIterable
to get the input from, may be nullpredicate
- the predicate to use, may not be null- Returns:
- the number of matches for the predicate in the collection
- Throws:
NullPointerException
- if predicate is null
-
duplicateList
Finds and returns the List of duplicate elements in the given collection.- Type Parameters:
E
- the type of elements in the collection.- Parameters:
iterable
- the list to test, must not be null.- Returns:
- the set of duplicate elements, may be empty.
- Since:
- 4.5.0-M3
-
duplicateSequencedSet
Finds and returns the sequenced Set of duplicate elements in the given collection.Once we are on Java 21 and a new major version, the return type should be SequencedSet.
- Type Parameters:
E
- the type of elements in the collection.- Parameters:
iterable
- the list to test, must not be null.- Returns:
- the set of duplicate elements, may be empty.
- Since:
- 4.5.0-M3
-
duplicateSet
Finds and returns the set of duplicate elements in the given collection.- Type Parameters:
E
- the type of elements in the collection.- Parameters:
iterable
- the list to test, must not be null.- Returns:
- the set of duplicate elements, may be empty.
- Since:
- 4.5.0-M3
-
emptyIfNull
Returns an immutable empty iterable if the argument is null, or the argument itself otherwise.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable, may be null- Returns:
- an empty iterable if the argument is null
-
emptyIterable
Gets an empty iterable.This iterable does not contain any elements.
- Type Parameters:
E
- the element type- Returns:
- an empty iterable
-
filteredIterable
public static <E> Iterable<E> filteredIterable(Iterable<E> iterable, Predicate<? super E> predicate) Returns a view of the given iterable that only contains elements matching the provided predicate.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to filter, may not be nullpredicate
- the predicate used to filter elements, may not be null- Returns:
- a filtered view on the specified iterable
- Throws:
NullPointerException
- if either iterable or predicate is null
-
find
Finds the first element in the given iterable which matches the given predicate.A
null
or empty iterator returns null.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to search, may be nullpredicate
- the predicate to use, must not be null- Returns:
- the first element of the iterable which matches the predicate or null if none could be found
- Throws:
NullPointerException
- if predicate is null
-
first
Shortcut forget(iterator, 0)
.Returns the
first
value in theiterable
'sIterator
, throwingIndexOutOfBoundsException
if there is no such element.If the
Iterable
is aList
, then it will useList.get(int)
.- Type Parameters:
T
- the type of object in theIterable
.- Parameters:
iterable
- theIterable
to get a value from, may be null- Returns:
- the first object
- Throws:
IndexOutOfBoundsException
- if the request is invalid- Since:
- 4.2
-
forEach
Applies the closure to each element of the provided iterable.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterator to use, may be nullclosure
- the closure to apply to each element, may not be null- Throws:
NullPointerException
- if closure is null
-
forEachButLast
Executes the given closure on each but the last element in the iterable.If the input iterable is null no change is made.
- Type Parameters:
E
- the type of object theIterable
contains- Parameters:
iterable
- the iterable to get the input from, may be nullclosure
- the closure to perform, may not be null- Returns:
- the last element in the iterable, or null if iterable is null or empty
-
frequency
Returns the number of occurrences of the provided object in the iterable. -
get
Returns theindex
-th value in theiterable
'sIterator
, throwingIndexOutOfBoundsException
if there is no such element.If the
Iterable
is aList
, then it will useList.get(int)
.- Type Parameters:
T
- the type of object in theIterable
.- Parameters:
iterable
- theIterable
to get a value from, may be nullindex
- the index to get- Returns:
- the object at the specified index
- Throws:
IndexOutOfBoundsException
- if the index is invalid
-
indexOf
Returns the index of the first element in the specified iterable that matches the given predicate.A
null
or empty iterable returns -1.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to search, may be nullpredicate
- the predicate to use, must not be null- Returns:
- the index of the first element which matches the predicate or -1 if none matches
- Throws:
NullPointerException
- if predicate is null
-
isEmpty
Answers true if the provided iterable is empty.A
null
iterable returns true.- Parameters:
iterable
- theto use
, may be null- Returns:
- true if the iterable is null or empty, false otherwise
-
loopingIterable
Returns a view of the given iterable which will cycle infinitely over its elements.The returned iterable's iterator supports
remove()
ifiterable.iterator()
does. Afterremove()
is called, subsequent cycles omit the removed element, which is no longer initerable
. The iterator'shasNext()
method returnstrue
untiliterable
is empty.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to loop, may not be null- Returns:
- a view of the iterable, providing an infinite loop over its elements
- Throws:
NullPointerException
- if iterable is null
-
matchesAll
Answers true if a predicate is true for every element of an iterable.A
null
or empty iterable returns true.- Type Parameters:
E
- the type of object theIterable
contains- Parameters:
iterable
- theIterable
to use, may be nullpredicate
- the predicate to use, may not be null- Returns:
- true if every element of the collection matches the predicate or if the collection is empty, false otherwise
- Throws:
NullPointerException
- if predicate is null
-
matchesAny
Answers true if a predicate is true for any element of the iterable.A
null
or empty iterable returns false.- Type Parameters:
E
- the type of object theIterable
contains- Parameters:
iterable
- theIterable
to use, may be nullpredicate
- the predicate to use, may not be null- Returns:
- true if any element of the collection matches the predicate, false otherwise
- Throws:
NullPointerException
- if predicate is null
-
partition
public static <O,R extends Collection<O>> List<R> partition(Iterable<? extends O> iterable, Factory<R> partitionFactory, Predicate<? super O>... predicates) Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicates.For each predicate, the returned list will contain a collection holding all elements of the input iterable matching the predicate. The last collection contained in the list will hold all elements which didn't match any predicate:
[C1, C2, R] = partition(I, P1, P2) with I = input P1 = first predicate P2 = second predicate C1 = collection of elements matching P1 C2 = collection of elements matching P2 R = collection of elements rejected by all predicates
Note: elements are only added to the output collection of the first matching predicate, determined by the order of arguments.
If the input iterable is
null
, the same is returned as for an empty iterable. If no predicates have been provided, all elements of the input collection will be added to the rejected collection.Example: for an input list [1, 2, 3, 4, 5] calling partition with predicates [x < 3] and [x < 5] will result in the following output: [[1, 2], [3, 4], [5]].
- Type Parameters:
O
- the type of object theIterable
containsR
- the type of the outputCollection
- Parameters:
iterable
- the collection to get the input from, may be nullpartitionFactory
- the factory used to create the output collectionspredicates
- the predicates to use, may not be null- Returns:
- a list containing the output collections
- Throws:
NullPointerException
- if any predicate is null
-
partition
public static <O> List<List<O>> partition(Iterable<? extends O> iterable, Predicate<? super O> predicate) Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicate.For each predicate, the result will contain a list holding all elements of the input iterable matching the predicate. The last list will hold all elements which didn't match any predicate:
[C1, R] = partition(I, P1) with I = input P1 = first predicate C1 = collection of elements matching P1 R = collection of elements rejected by all predicates
If the input iterable is
null
, the same is returned as for an empty iterable.Example: for an input list [1, 2, 3, 4, 5] calling partition with a predicate [x < 3] will result in the following output: [[1, 2], [3, 4, 5]].
- Type Parameters:
O
- the type of object theIterable
contains- Parameters:
iterable
- the iterable to partition, may be nullpredicate
- the predicate to use, may not be null- Returns:
- a list containing the output collections
- Throws:
NullPointerException
- if predicate is null
-
partition
public static <O> List<List<O>> partition(Iterable<? extends O> iterable, Predicate<? super O>... predicates) Partitions all elements from iterable into separate output collections, based on the evaluation of the given predicates.For each predicate, the result will contain a list holding all elements of the input iterable matching the predicate. The last list will hold all elements which didn't match any predicate:
[C1, C2, R] = partition(I, P1, P2) with I = input P1 = first predicate P2 = second predicate C1 = collection of elements matching P1 C2 = collection of elements matching P2 R = collection of elements rejected by all predicates
Note: elements are only added to the output collection of the first matching predicate, determined by the order of arguments.
If the input iterable is
null
, the same is returned as for an empty iterable.Example: for an input list [1, 2, 3, 4, 5] calling partition with predicates [x < 3] and [x < 5] will result in the following output: [[1, 2], [3, 4], [5]].
- Type Parameters:
O
- the type of object theIterable
contains- Parameters:
iterable
- the collection to get the input from, may be nullpredicates
- the predicates to use, may not be null- Returns:
- a list containing the output collections
- Throws:
NullPointerException
- if any predicate is null
-
reversedIterable
Returns a reversed view of the given iterable.In case the provided iterable is a
List
instance, aReverseListIterator
will be used to reverse the traversal order, otherwise an intermediateList
needs to be created.The returned iterable's iterator supports
remove()
if the provided iterable is aList
instance.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to use, may not be null- Returns:
- a reversed view of the specified iterable
- Throws:
NullPointerException
- if iterable is null- See Also:
-
size
Returns the number of elements contained in the given iterator.A
null
or empty iterator returns0
.- Parameters:
iterable
- the iterable to check, may be null- Returns:
- the number of elements contained in the iterable
-
skippingIterable
Returns a view of the given iterable that skips the first N elements.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to use, may not be nullelementsToSkip
- the number of elements to skip from the start, must not be negative- Returns:
- a view of the specified iterable, skipping the first N elements
- Throws:
IllegalArgumentException
- if elementsToSkip is negativeNullPointerException
- if iterable is null
-
toList
Gets a new list with the contents of the provided iterable.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to use, may be null- Returns:
- a list of the iterator contents
-
toString
Returns a string representation of the elements of the specified iterable.The string representation consists of a list of the iterable's elements, enclosed in square brackets (
"[]"
). Adjacent elements are separated by the characters", "
(a comma followed by a space). Elements are converted to strings as byString.valueOf(Object)
.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to convert to a string, may be null- Returns:
- a string representation of
iterable
-
toString
Returns a string representation of the elements of the specified iterable.The string representation consists of a list of the iterable's elements, enclosed in square brackets (
"[]"
). Adjacent elements are separated by the characters", "
(a comma followed by a space). Elements are converted to strings as by using the providedtransformer
.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to convert to a string, may be nulltransformer
- the transformer used to get a string representation of an element- Returns:
- a string representation of
iterable
- Throws:
NullPointerException
- iftransformer
is null
-
toString
public static <E> String toString(Iterable<E> iterable, Transformer<? super E, String> transformer, String delimiter, String prefix, String suffix) Returns a string representation of the elements of the specified iterable.The string representation consists of a list of the iterable's elements, enclosed by the provided
prefix
andsuffix
. Adjacent elements are separated by the provideddelimiter
. Elements are converted to strings as by using the providedtransformer
.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to convert to a string, may be nulltransformer
- the transformer used to get a string representation of an elementdelimiter
- the string to delimit elementsprefix
- the prefix, prepended to the string representationsuffix
- the suffix, appended to the string representation- Returns:
- a string representation of
iterable
- Throws:
NullPointerException
- if either transformer, delimiter, prefix or suffix is null
-
transformedIterable
public static <I,O> Iterable<O> transformedIterable(Iterable<I> iterable, Transformer<? super I, ? extends O> transformer) Returns a transformed view of the given iterable where all of its elements have been transformed by the provided transformer.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
I
- the input element typeO
- the output element type- Parameters:
iterable
- the iterable to transform, may not be nulltransformer
- the transformer, must not be null- Returns:
- a transformed view of the specified iterable
- Throws:
NullPointerException
- if either iterable or transformer is null
-
uniqueIterable
Returns a unique view of the given iterable.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it. Callingremove()
will only remove a single element from the underlying iterator.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to use, may not be null- Returns:
- a unique view of the specified iterable
- Throws:
NullPointerException
- if iterable is null
-
unmodifiableIterable
Returns an unmodifiable view of the given iterable.The returned iterable's iterator does not support
remove()
.- Type Parameters:
E
- the element type- Parameters:
iterable
- the iterable to use, may not be null- Returns:
- an unmodifiable view of the specified iterable
- Throws:
NullPointerException
- if iterable is null
-
zippingIterable
Interleaves two iterables into a single iterable.The returned iterable has an iterator that traverses the elements in
a
andb
in alternating order. The source iterators are not polled until necessary.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
a
- the first iterable, may not be nullb
- the second iterable, may not be null- Returns:
- a new iterable, interleaving the provided iterables
- Throws:
NullPointerException
- if either a or b is null
-
zippingIterable
public static <E> Iterable<E> zippingIterable(Iterable<? extends E> first, Iterable<? extends E>... others) Interleaves two iterables into a single iterable.The returned iterable has an iterator that traverses the elements in
a
andb
in alternating order. The source iterators are not polled until necessary.The returned iterable's iterator supports
remove()
when the corresponding input iterator supports it.- Type Parameters:
E
- the element type- Parameters:
first
- the first iterable, may not be nullothers
- the array of iterables to interleave, may not be null- Returns:
- a new iterable, interleaving the provided iterables
- Throws:
NullPointerException
- if either of the provided iterables is null
-