|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.metrics2.util.TryIterator<T>
T
- the type of the iteratorpublic abstract class TryIterator<T>
A base class for unmodifiable iterators (throws on remove) This class also makes writing filtering iterators easier, where the only way to discover the end of data is by trying to read it. The same applies to writing iterator wrappers around stream read calls. One only needs to implement the tryNext() method and call done() when done.
Constructor Summary | |
---|---|
TryIterator()
|
Method Summary | |
---|---|
T |
current()
|
protected T |
done()
Implementations of tryNext() must call this method
when there are no more elements left in the iteration. |
boolean |
hasNext()
|
T |
next()
|
void |
remove()
Guaranteed to throw UnsupportedOperationException |
protected abstract T |
tryNext()
Return the next element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TryIterator()
Method Detail |
---|
protected abstract T tryNext()
done()
when done, otherwise
infinite loop could occur. If this method throws an exception, any
further attempts to use the iterator would result in an
IllegalStateException
.
done()
protected final T done()
tryNext()
must call this method
when there are no more elements left in the iteration.
tryNext()
public final boolean hasNext()
hasNext
in interface Iterator<T>
public final T next()
next
in interface Iterator<T>
public final T current()
public final void remove()
remove
in interface Iterator<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |