public class NiceIterator<T> extends Object implements ExtendedIterator<T>
andThen, filterKeep and
filterDrop; these can be reused from any other class. It defines
equivalent instance methods for descendants and to satisfy ExtendedIterator.| Constructor and Description |
|---|
NiceIterator() |
| Modifier and Type | Method and Description |
|---|---|
static <T> ExtendedIterator<T> |
andThen(Iterator<T> a,
Iterator<? extends T> b)
concatenate two closable iterators.
|
<X extends T> |
andThen(Iterator<X> other)
make a new iterator, which is us then the other chap.
|
static <T> List<T> |
asList(ExtendedIterator<T> it)
Answer a list of the elements from
it, in order, consuming
that iterator. |
static <T> Set<T> |
asSet(ExtendedIterator<T> it)
Answer a list of the elements of
it in order, consuming this iterator. |
void |
close()
default close: don't need to do anything.
|
static void |
close(Iterator<?> it)
If
it is a Closableiterator, close it. |
static <T> ExtendedIterator<T> |
emptyIterator()
An iterator over no elements.
|
FilterIterator<T> |
filterDrop(Predicate<T> f)
make a new iterator, which is our elements that do not pass the filter
|
FilterIterator<T> |
filterKeep(Predicate<T> f)
make a new iterator, which is our elements that pass the filter
|
boolean |
hasNext()
default hasNext: no elements, return false.
|
<U> ExtendedIterator<U> |
mapWith(Function<T,U> map1)
make a new iterator which is the elementwise _map1_ of the base iterator.
|
T |
next()
default next: throw an exception.
|
void |
remove()
default remove: we have no elements, so we can't remove any.
|
T |
removeNext()
Answer the next object, and remove it.
|
List<T> |
toList()
Answer a list of the elements in order, consuming this iterator.
|
Set<T> |
toSet()
Answer a list of the elements in order, consuming this iterator.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnextOptionalforEachRemainingpublic void close()
close in interface ClosableIterator<T>public boolean hasNext()
public void remove()
public T removeNext()
removeNext in interface ExtendedIterator<T>public static <T> ExtendedIterator<T> andThen(Iterator<T> a, Iterator<? extends T> b)
public <X extends T> ExtendedIterator<T> andThen(Iterator<X> other)
andThen in interface ExtendedIterator<T>public FilterIterator<T> filterKeep(Predicate<T> f)
filterKeep in interface ExtendedIterator<T>public FilterIterator<T> filterDrop(Predicate<T> f)
filterDrop in interface ExtendedIterator<T>public <U> ExtendedIterator<U> mapWith(Function<T,U> map1)
mapWith in interface ExtendedIterator<T>public static void close(Iterator<?> it)
it is a Closableiterator, close it. Abstracts away from
tests [that were] scattered through the code.public static <T> ExtendedIterator<T> emptyIterator()
public List<T> toList()
toList in interface ExtendedIterator<T>public Set<T> toSet()
toSet in interface ExtendedIterator<T>public static <T> Set<T> asSet(ExtendedIterator<T> it)
it in order, consuming this iterator.
Canonical implementation of toSet().public static <T> List<T> asList(ExtendedIterator<T> it)
it, in order, consuming
that iterator. Canonical implementation of toList().Licenced under the Apache License, Version 2.0