public class Iterators extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Iterators.Indexed<T> |
static class |
Iterators.IteratorStack<V>
A utility class for dynamically appending and prepending iterators to a collection, which itself can be iterated
over.
|
Constructor and Description |
---|
Iterators() |
Modifier and Type | Method and Description |
---|---|
static <V> Iterator<V> |
concat(Iterator<V>... iterators) |
static <V> Iterator<V> |
drop(Iterator<V> it,
long n) |
static <V> boolean |
equals(Iterator<V> a,
Iterator<V> b,
BiPredicate<V,V> equals) |
static <V> Iterator<V> |
filter(Iterator<V> it,
Predicate<V> f) |
static <U,V> Iterator<V> |
flatMap(Iterator<U> it,
Function<U,Iterator<V>> f) |
static <V> Iterator<V> |
from(BooleanSupplier hasNext,
Supplier<V> next) |
static <V> Iterator<Iterators.Indexed<V>> |
indexed(Iterator<V> it) |
static <V> Iterator<Iterators.Indexed<V>> |
indexed(Iterator<V> it,
long offset) |
static <U,V> Iterator<V> |
map(Iterator<U> it,
Function<U,V> f) |
static <V> Iterator<V> |
mergeSort(IList<Iterator<V>> iterators,
Comparator<V> comparator) |
static <V> Iterator<V> |
onExhaustion(Iterator<V> it,
Runnable f) |
static <V> Iterator<V> |
range(long max,
LongFunction<V> f)
Represents a range implicitly starting at 0.
|
static <V> Iterator<V> |
range(long min,
long max,
LongFunction<V> f) |
static <V> Iterator<V> |
singleton(V val) |
static <V> IDurableEncoding.SkippableIterator |
skippable(Iterator<V> it) |
static <V> Stream<V> |
toStream(Iterator<V> it) |
static <V> Stream<V> |
toStream(Iterator<V> it,
long estimatedSize) |
public static final Iterator EMPTY
public static <V> Iterator<V> mergeSort(IList<Iterator<V>> iterators, Comparator<V> comparator)
public static <V> boolean equals(Iterator<V> a, Iterator<V> b, BiPredicate<V,V> equals)
public static <V> Iterator<V> from(BooleanSupplier hasNext, Supplier<V> next)
public static <V> Iterator<V> singleton(V val)
public static <V> Iterator<V> filter(Iterator<V> it, Predicate<V> f)
it
- an iteratorf
- a predicatepublic static <U,V> Iterator<V> map(Iterator<U> it, Function<U,V> f)
it
- an iteratorf
- a function which transforms valuespublic static <U,V> Iterator<V> flatMap(Iterator<U> it, Function<U,Iterator<V>> f)
it
- an iteratorf
- a function which transforms values into iteratorspublic static <V> Iterator<V> range(long min, long max, LongFunction<V> f)
min
- an inclusive start of the rangemax
- an exclusive end of the rangef
- a function which transforms a number in the range into a valuef
public static <V> Iterator<V> range(long max, LongFunction<V> f)
max
- an exclusive end of the range.f
- a function which transforms a number in the range into a value.f
public static <V> Iterator<V> concat(Iterator<V>... iterators)
iterators
- a list of iteratorspublic static <V> Iterator<V> drop(Iterator<V> it, long n)
it
- an iteratorn
- the number of elements to drop, which may be larger than the number of values in the iteratorn
values droppedpublic static <V> IDurableEncoding.SkippableIterator skippable(Iterator<V> it)
public static <V> Iterator<Iterators.Indexed<V>> indexed(Iterator<V> it)
public static <V> Iterator<Iterators.Indexed<V>> indexed(Iterator<V> it, long offset)