public class IteratorToolkit extends Object
Constructor and Description |
---|
IteratorToolkit() |
Modifier and Type | Method and Description |
---|---|
static <T> Iterator<T> |
filter(Iterator<T> itr,
IPredicate<? super T> filter)
Wrap an iterator in a new iterator that filters out values based on a predicate.
|
static <T> Iterator<T> |
of(T[] elements)
Iterator that iterates over an array.
|
static <T> Iterator<T> |
skipNulls(Iterator<T> itr)
Wrap an iterator in a new iterator that skips all null values.
|
static <T> List<T> |
toList(Iterator<T> itr,
int sizeHint)
Place all elements of an iterator in a list.
|
public static <T> List<T> toList(Iterator<T> itr, int sizeHint)
T
- input iterator typeitr
- iteratorsizeHint
- a hint of how many elements there arepublic static <T> Iterator<T> skipNulls(Iterator<T> itr)
T
- input iterator typeitr
- input iterator that may produce null valuespublic static <T> Iterator<T> filter(Iterator<T> itr, IPredicate<? super T> filter)
T
- input iterator typeitr
- input iteratorfilter
- filter predicatepublic static <T> Iterator<T> of(T[] elements)
T
- input iterator typeelements
- elements to iterate overCopyright © 2018. All rights reserved.