Modifier and Type | Class and Description |
---|---|
static interface |
IteratorUtil.ArrayIterator<T>
An
Iterator that has a notion of an "array index", which is the index of the "next" element in an
array. |
Modifier and Type | Field and Description |
---|---|
static Iterator |
AT_END
An iterator which is at its end.
|
Modifier and Type | Method and Description |
---|---|
static <T> void |
addAllElementsTo(Iterator<? extends T> iterator,
Collection<? super T> target)
Adds all remaining products of the iterator to the target collection.
|
static <T> Iterator<T> |
atEnd() |
static int |
elementCount(Iterator<Integer> iterator)
Retrieves, counts and discards all elements remaining on the iterator
|
static <T> Iterator<T> |
filter(Iterator<? extends T> delegate,
PredicateWhichThrows<? super T,? extends RuntimeException> qualifies)
Returns an iterator which skips the elements of the delegate which do not qualifiy.
|
static Iterator<Integer> |
foR(int start,
int end)
|
static Iterator<Integer> |
foR(int start,
int end,
int step)
Creates and returns an
Iterator<Integer> that counts from start (inclusively) to
end (exclusively), with a step increment. |
static <T> IteratorUtil.ArrayIterator<T> |
iterator(T[] array) |
static <T> Iterator<ElementWithContext<T>> |
iteratorWithContext(Iterator<? extends T> delegate)
Wraps the delegate iterator in an
Iterator<ElementWithContext> . |
static <T> Iterator<T> |
repeat(int n,
T value) |
static <T> Iterator<T> |
repeat(T value) |
static <E> ListIterator<E> |
reverse(ListIterator<E> delegate)
Returns a list iterator that traverses the list elements in the reverse order of the given delegate.
|
static <I,O> Iterator<O> |
transform(Iterator<? extends I> delegate,
Transformer<? super I,? extends O> transform)
Returns an iterator which iterates the transformed elements of the delegate
|
public static <T> Iterator<T> filter(Iterator<? extends T> delegate, PredicateWhichThrows<? super T,? extends RuntimeException> qualifies)
public static <I,O> Iterator<O> transform(Iterator<? extends I> delegate, Transformer<? super I,? extends O> transform)
public static <T> Iterator<T> repeat(T value)
public static <E> ListIterator<E> reverse(ListIterator<E> delegate)
Notice that iff !
delegate.hasPrevious()
, then !reverse(
delegate).hasNext()
. In other words, you will often use
IteratorUtil.reverse(list.listIterator(list.size()))
, and not simply
IteratorUtil.reverse(list.listIterator())
public static <T> Iterator<T> repeat(int n, T value)
public static <T> IteratorUtil.ArrayIterator<T> iterator(T[] array)
public static int elementCount(Iterator<Integer> iterator)
public static <T> Iterator<ElementWithContext<T>> iteratorWithContext(Iterator<? extends T> delegate)
Iterator<ElementWithContext>
.delegate
- Must produce non-null
valuesElementWithContext
s from the sequence produced by the
delegatepublic static Iterator<Integer> foR(int start, int end)
foR(int, int, int)
public static Iterator<Integer> foR(int start, int end, int step)
Iterator<Integer>
that counts from start (inclusively) to
end (exclusively), with a step increment.
More precise: Iff step is greater than zero, then the returned iterator produces the values
start, start +
step, and so forth, and ends with the last value which
is less than end.
Otherwise, iff step is less than zero, then the returned iterator produces the values
start, start +
step, and so forth, and ends with the last value which
is greater than end.
Otherwise, step is zero, and the returned iterator produces either an
infinite sequence of values start, or, iff start ==
end, an empty
sequence.
IllegalArgumentException
- step > 0 &&
end <
startIllegalArgumentException
- step < 0 &&
end >
startpublic static <T> void addAllElementsTo(Iterator<? extends T> iterator, Collection<? super T> target)
Copyright © 2018 Arno Unkrig. All rights reserved.