Class FilteringIterator<T>
- java.lang.Object
-
- ru.ispras.testbase.knowledge.iterator.FilteringIterator<T>
-
- Type Parameters:
T
- the item type.
- All Implemented Interfaces:
Iterator<T>
- Direct Known Subclasses:
FpSqrtHardToDRoundIterator
,FpSqrtHardToNRoundIterator
public class FilteringIterator<T> extends java.lang.Object implements Iterator<T>
FilteringIterator
implements an iterator filter based on a cache of values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FilteringIterator.Type
This enumeration contains equality checking types.
-
Constructor Summary
Constructors Constructor Description FilteringIterator(FilteringIterator<T> other)
Constructs a copy of the iterator.FilteringIterator(Iterator<T> iterator)
Constructs a filtering iterator with the unlimited cache size.FilteringIterator(Iterator<T> iterator, int size)
Constructs a filtering iterator.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
FilteringIterator
public FilteringIterator(Iterator<T> iterator, FilteringIterator.Type type, int size)
Constructs a filtering iterator.- Parameters:
iterator
- the base iterator.type
- the equality checking type.size
- the cache size.
-
FilteringIterator
public FilteringIterator(Iterator<T> iterator, FilteringIterator.Type type)
Constructs a filtering iterator with the unlimited cache size.- Parameters:
iterator
- the base iterator.type
- the equality checking type.
-
FilteringIterator
public FilteringIterator(Iterator<T> iterator, int size)
Constructs a filtering iterator.- Parameters:
iterator
- the base iterator.size
- the cache size.
-
FilteringIterator
public FilteringIterator(Iterator<T> iterator)
Constructs a filtering iterator with the unlimited cache size.- Parameters:
iterator
- the base iterator.
-
FilteringIterator
public FilteringIterator(FilteringIterator<T> other)
Constructs a copy of the iterator.- Parameters:
other
- the iterator to be copied.
-
-
Method Detail
-
equals
protected boolean equals(T lhs, T rhs)
Checks whether two values are equal (can be overloaded in a subclass).- Parameters:
lhs
- the left-hand-side value.rhs
- the right-hand-side value.- Returns:
true
if the value are equal;false
otherwise.
-
init
public void init()
Description copied from interface:Iterator
Initializes the iterator.
-
hasValue
public boolean hasValue()
Description copied from interface:Iterator
Checks if the iterator is not exhausted (a value is available).
-
value
public T value()
Description copied from interface:Iterator
Returns the current value of the iterator.
-
next
public void next()
Description copied from interface:Iterator
Makes an iteration.
-
stop
public void stop()
Description copied from interface:Iterator
Stops the iterator.
-
-