public class IteratorUtils2
extends java.lang.Object
IteratorUtils.| Modifier and Type | Class and Description |
|---|---|
static interface |
IteratorUtils2.Zipper<L,R,O>
Zips two input into another
|
| Constructor and Description |
|---|
IteratorUtils2() |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Iterator<T> |
chainedIterator(java.util.Iterator<T>... iterators)
Converts array of iterators to chained iterator
|
static int |
countElements(java.util.Iterator<?> itr)
Returns the number of elements in the java.util.Iterator.
|
static <T> java.util.Iterator<T> |
emptyIterator() |
static <E> E |
getElement(java.util.Iterator<E> itr,
int index) |
static <E> java.util.Iterator<E> |
rangeIterator(java.util.Iterator<E> itr,
int off,
int len) |
static <T> T[] |
toArray(java.util.Iterator<? extends T> iterator,
java.lang.Class<T> arrayClass)
Added this method as the similar method from "commons/collections15" did
not allow the iterator to hold items that is a subclass from the generic
type.
|
static <T> java.lang.Iterable<T> |
toIterable(java.util.Iterator<T> itr)
Converts iterator to Iterable
|
static <T> java.util.List<T> |
toList(java.util.Iterator<T> itr)
Converts iterator to List
|
static <L,R,O> java.util.Iterator<O> |
zippedIterator(java.util.Iterator<L> left,
java.util.Iterator<R> right,
IteratorUtils2.Zipper<L,R,O> zipper)
Converts two iterators to zipped iterator
|
public static int countElements(java.util.Iterator<?> itr)
itr - the java.util.Iterator to count.public static <E> java.util.Iterator<E> rangeIterator(java.util.Iterator<E> itr,
int off,
int len)
public static <E> E getElement(java.util.Iterator<E> itr,
int index)
public static <T> java.util.Iterator<T> emptyIterator()
public static <T> T[] toArray(java.util.Iterator<? extends T> iterator,
java.lang.Class<T> arrayClass)
iterator - The iterator of itemsarrayClass - The array class type.public static <T> java.util.List<T> toList(java.util.Iterator<T> itr)
itr - The Iterator to be converted.public static <T> java.lang.Iterable<T> toIterable(java.util.Iterator<T> itr)
itr - The Iterator to be converted.@SafeVarargs public static <T> java.util.Iterator<T> chainedIterator(java.util.Iterator<T>... iterators)
iterators - The Iterators to be chained.public static <L,R,O> java.util.Iterator<O> zippedIterator(java.util.Iterator<L> left,
java.util.Iterator<R> right,
IteratorUtils2.Zipper<L,R,O> zipper)
left - The Iterators to be zipped.right - The Iterators to be zipped.zipper - The ZipperCopyright ? Technia AB. All Rights Reserved.