almost.functional.utils
public final class Iterators extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.List<T> |
collect(java.util.Iterator<T> iterator)
Collect an iterator's elements into a List.
|
static <T> java.util.Iterator<T> |
concat(java.util.Iterator<? extends T>... iterators)
Create an iterator which sequentially iterates over a collection of iterators.
|
static <T> java.util.Iterator<T> |
next(java.util.Iterator<? extends T> iterator,
int count)
This returns an Iterator limited to no more then the next count elements.
|
static <T> void |
parallelBatch(java.util.Iterator<? extends T> iterator,
Consumer<java.util.Iterator<? extends T>> consumer,
int batchSize)
Break an iterator's elements into batches, and invoke the consumer on these batches in a thread pool.
|
public static <T> java.util.Iterator<T> next(java.util.Iterator<? extends T> iterator,
int count)
T - the element type.iterator - the iterator to draw elements from.count - the maximum number of elements to draw.public static <T> java.util.List<T> collect(java.util.Iterator<T> iterator)
T - the element typeiterator - the iteratorpublic static <T> void parallelBatch(java.util.Iterator<? extends T> iterator,
Consumer<java.util.Iterator<? extends T>> consumer,
int batchSize)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
T - the element typeiterator - the iterator to draw elements fromconsumer - the Consumer to use the batchesbatchSize - the maximum number of elements per batchjava.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic static <T> java.util.Iterator<T> concat(java.util.Iterator<? extends T>... iterators)
T - the element typeiterators - the iterators to iterate