| Modifier and Type | Field and Description |
|---|---|
static Iterator |
EMPTY_ITERATOR
The empty
Iterator. |
| Modifier and Type | Method and Description |
|---|---|
static <E> Iterator<E> |
concat(Iterator<? extends E>... iterators)
Concatenates all the given
Iterators into a single one. |
static <E> Iterator<E> |
concat(Iterator<? extends Iterator<? extends E>> iterators)
Concatenates all the given
Iterators into a single one. |
static <E> Iterator<E> |
cycle(E... elements)
Returns an
Iterator that cycles indefinitely over the given
elements. |
static <E> Iterator<E> |
cycle(Iterator<? extends E> iterator)
Returns an
Iterator that cycles indefinitely over the content
of the given source Iterator. |
static <E> Iterator<E> |
emptyIterator()
Returns the empty
Iterator for a particular type (type-safe). |
static boolean |
equal(Iterator<?> i1,
Iterator<?> i2)
Returns whether the given
Iterators contain equal elements in
the same order. |
static <E> Iterator<E> |
limit(Iterator<? extends E> iterator,
int limit)
Creates an
Iterator returning only the first limit
elements of the given Iterator. |
static int |
skip(Iterator<?> iterator,
int n)
Skips
n elements from the given Iterator. |
static <E> Bag<E> |
toBag(Iterator<? extends E> iterator)
Returns a
Bag containing all the given Iterator's
elements. |
static <E> List<E> |
toList(Iterator<? extends E> iterator)
Returns a
List containing all the given Iterator's
elements. |
static <E> Set<E> |
toSet(Iterator<? extends E> iterator)
Returns a
Set containing all the given Iterator's
elements. |
static String |
toString(Iterator<?> iterator)
Returns a
String representation of the given Iterator,
using the "[e1, e2, ..., en]" format. |
public static final Iterator EMPTY_ITERATOR
Iterator.public static <E> Iterator<E> emptyIterator()
Iterator for a particular type (type-safe).
Note that unlike this method, the like-named static field does not
provide type safety.E - the type of the Iterator's elements.Iterator.public static <E> Iterator<E> concat(Iterator<? extends E>... iterators)
Iterators into a single one. The
source Iterators aren't polled until necessary. The returned
Iterator supports Iterator.remove() when the
corresponding input Iterator supports it.E - the type of the returned Iterator's elements.iterators - the Iterators to concatenate.Iterator.NullPointerException - if iterators is null or
if it contains a null reference.public static <E> Iterator<E> concat(Iterator<? extends Iterator<? extends E>> iterators)
Iterators into a single one. The
source Iterators aren't polled until necessary. The returned
Iterator supports Iterator.remove() when the
corresponding input Iterator supports it.E - the type of the returned Iterator's elements.iterators - the Iterators to concatenate.Iterator.NullPointerException - if iterators is null or
if it contains a null reference.public static <E> Iterator<E> cycle(Iterator<? extends E> iterator)
Iterator that cycles indefinitely over the content
of the given source Iterator. The source Iterator is
not polled until necessary. The returned Iterator supports
Iterator.remove().E - the type of the returned Iterator's elements.iterator - the source Iterator.Iterator.NullPointerException - if iterator is null.public static <E> Iterator<E> cycle(E... elements)
Iterator that cycles indefinitely over the given
elements. The returned Iterator supports Iterator.remove().E - the type of the returned Iterator's elements.elements - the elements to cycle over.Iterator.NullPointerException - if elements is null.public static boolean equal(Iterator<?> i1, Iterator<?> i2)
Iterators contain equal elements in
the same order. Note that this method consumes entirely the input
Iterators.i1 - the first Iterator.i2 - the second Iterator.Iterator have the same content.public static <E> Iterator<E> limit(Iterator<? extends E> iterator, int limit)
Iterator returning only the first limit
elements of the given Iterator. The source Iterator
is not polled until necessary. The returned Iterator supports
Iterator.remove() if the source Iterator supports it.E - the type of the returned Iterator's elements.iterator - the Iterator to limit.limit - the number of elements in the returned Iterator.Iterator.NullPointerException - if iterator is null.IllegalArgumentException - if (limit is negative.public static int skip(Iterator<?> iterator, int n)
n elements from the given Iterator.iterator - the Iterator.n - the number of elements to skip.NullPointerException - if iterator is null.IllegalArgumentException - if (n is negative.public static <E> List<E> toList(Iterator<? extends E> iterator)
List containing all the given Iterator's
elements. This method consumes entirely the input Iterator.E - the type of the returned List's elements.iterator - the Iterator to consume.List created from the given Iterator.NullPointerException - if iterator is null.public static <E> Set<E> toSet(Iterator<? extends E> iterator)
Set containing all the given Iterator's
elements. The returned Set has the same iteration order as
the given Iterator. This method consumes entirely the input
Iterator.E - the type of the returned Set's elements.iterator - the Iterator to consume.Set created from the given Iterator.NullPointerException - if iterator is null.public static <E> Bag<E> toBag(Iterator<? extends E> iterator)
Bag containing all the given Iterator's
elements. The returned Bag has the same iteration order as
the given Iterator. This method consumes entirely the input
Iterator.E - the type of the returned Bag's elements.iterator - the Iterator to consume.Bag created from the given Iterator.NullPointerException - if iterator is null.public static String toString(Iterator<?> iterator)
String representation of the given Iterator,
using the "[e1, e2, ..., en]" format. This method consumes entirely
the input Iterator.iterator - the Iterator.String created from the given Iterator.NullPointerException - if iterator is null.Copyright © 2012–2015. All rights reserved.