T
- the item type.public class FilteringIterator<T> extends java.lang.Object implements Iterator<T>
FilteringIterator
implements an iterator filter based on a cache of values.Modifier and Type | Class and Description |
---|---|
static class |
FilteringIterator.Type
This enumeration contains equality checking types.
|
Constructor and Description |
---|
FilteringIterator(FilteringIterator<T> r)
Constructs a copy of the iterator.
|
FilteringIterator(Iterator<T> iterator)
Constructs a filtering iterator with the unlimited cache size.
|
FilteringIterator(Iterator<T> iterator,
FilteringIterator.Type type)
Constructs a filtering iterator with the unlimited cache size.
|
FilteringIterator(Iterator<T> iterator,
FilteringIterator.Type type,
int size)
Constructs a filtering iterator.
|
FilteringIterator(Iterator<T> iterator,
int size)
Constructs a filtering iterator.
|
Modifier and Type | Method and Description |
---|---|
FilteringIterator<T> |
clone()
Creates a copy of the iterator.
|
protected boolean |
equals(T lhs,
T rhs)
Checks whether two values are equal (can be overloaded in a subclass).
|
boolean |
hasValue()
Checks if the iterator is not exhausted (a value is available).
|
void |
init()
Initializes the iterator.
|
void |
next()
Makes an iteration.
|
void |
stop()
Stops the iterator.
|
T |
value()
Returns the current value of the iterator.
|
public FilteringIterator(Iterator<T> iterator, FilteringIterator.Type type, int size)
iterator
- the base iterator.type
- the equality checking type.size
- the cache size.public FilteringIterator(Iterator<T> iterator, FilteringIterator.Type type)
iterator
- the base iterator.type
- the equality checking type.public FilteringIterator(Iterator<T> iterator, int size)
iterator
- the base iterator.size
- the cache size.public FilteringIterator(Iterator<T> iterator)
iterator
- the base iterator.public FilteringIterator(FilteringIterator<T> r)
r
- the iterator to be copied.protected boolean equals(T lhs, T rhs)
lhs
- the left-hand-side value.rhs
- the right-hand-side value.true
if the value are equal; false
otherwise.public void init()
Iterator
public boolean hasValue()
Iterator
public T value()
Iterator
public void next()
Iterator
public void stop()
Iterator