|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.inject.internal.util.Iterators
public final class Iterators
This class contains static utility methods that operate on or return objects
of type Iterator. Also see the parallel implementations in Iterables.
| Method Summary | ||
|---|---|---|
static
|
asEnumeration(Iterator<T> iterator)
Adapts an Iterator to the Enumeration interface. |
|
static
|
concat(Iterator<? extends Iterator<? extends T>> inputs)
Combines multiple iterators into a single iterator. |
|
static
|
emptyIterator()
Returns the empty Iterator. |
|
static
|
emptyListIterator()
Returns the empty ListIterator. |
|
static
|
forArray(T... array)
Returns an iterator containing the elements of array in order. |
|
static
|
forArray(T[] array,
int offset,
int length)
Returns an iterator containing the elements in the specified range of array in order. |
|
static
|
getOnlyElement(Iterator<T> iterator)
Returns the single element contained in iterator. |
|
static
|
singletonIterator(T value)
Returns an iterator containing only value. |
|
static String |
toString(Iterator<?> iterator)
Returns a string representation of iterator, with the format
[e1, e2, ..., en]. |
|
static
|
transform(Iterator<F> fromIterator,
Function<? super F,? extends T> function)
Returns an iterator that applies function to each element of fromIterator. |
|
static
|
unmodifiableIterator(Iterator<T> iterator)
Returns an unmodifiable view of iterator. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> UnmodifiableIterator<T> emptyIterator()
Iterator.
public static <T> ListIterator<T> emptyListIterator()
ListIterator.
public static <T> UnmodifiableIterator<T> unmodifiableIterator(Iterator<T> iterator)
iterator.
public static String toString(Iterator<?> iterator)
iterator, with the format
[e1, e2, ..., en]. The iterator will be left exhausted: its
hasNext() method will return false.
public static <T> T getOnlyElement(Iterator<T> iterator)
iterator.
NoSuchElementException - if the iterator is empty
IllegalArgumentException - if the iterator contains multiple
elements. The state of the iterator is unspecified.public static <T> Iterator<T> concat(Iterator<? extends Iterator<? extends T>> inputs)
inputs. The input
iterators are not polled until necessary.
The returned iterator supports remove() when the corresponding
input iterator supports it. The methods of the returned iterator may throw
NullPointerException if any of the input iterators are null.
public static <F,T> Iterator<T> transform(Iterator<F> fromIterator,
Function<? super F,? extends T> function)
function to each element of fromIterator.
The returned iterator supports remove() if the provided iterator
does. After a successful remove() call, fromIterator no
longer contains the corresponding element.
public static <T> UnmodifiableIterator<T> forArray(T... array)
array in order. The
returned iterator is a view of the array; subsequent changes to the array
will be reflected in the iterator.
Note: It is often preferable to represent your data using a
collection type, for example using Arrays.asList(Object[]), making
this method unnecessary.
public static <T> UnmodifiableIterator<T> forArray(T[] array,
int offset,
int length)
array in order. The returned iterator is a view of the array;
subsequent changes to the array will be reflected in the iterator.
array - array to read elements out ofoffset - index of first array element to retrievelength - number of elements in iteration
IndexOutOfBoundsException - if offset is negative,
length is negative, or offset + length > array.length
public static <T> UnmodifiableIterator<T> singletonIterator(@Nullable
T value)
value.
public static <T> Enumeration<T> asEnumeration(Iterator<T> iterator)
Iterator to the Enumeration interface.
Collections.enumeration(Collection)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||