Package org.yamcs.utils
Interface PeekingIterator<T>
- Type Parameters:
T
- the type of elements returned by this iterator
- All Known Subinterfaces:
ParameterIterator
,ParchiveIterator<T>
- All Known Implementing Classes:
AggrrayIterator
,MultiSegmentIterator
,SegmentIterator
,SimpleParameterIterator
public interface PeekingIterator<T>
An interface for an iterator that allows peeking at the current value.
The advantage over the standard java iterator is that because the value can be looked at, it can be used in priority queues to run multiple of them in parallel.
-
Method Summary
-
Method Details
-
isValid
boolean isValid()Returnstrue
if the iterator has more elements.This method allows to verify whether the iterator has a valid value to be fetched.
- Returns:
true
if the iterator has more elements orfalse
otherwise
-
value
T value()Returns the current value from the iterator without advancing.This method can only be called if
isValid()
returnstrue
. If called afterisValid()
returnsfalse
, this method will throw an exception.- Returns:
- the current element
- Throws:
IllegalStateException
- ifisValid()
returnsfalse
-
next
void next()Moves the iterator to the next element.If
isValid()
returnsfalse
, calling this method has no effect.
-