Package com.carrotsearch.hppc
Class AbstractIterator<E>
- java.lang.Object
-
- com.carrotsearch.hppc.AbstractIterator<E>
-
- All Implemented Interfaces:
java.util.Iterator<E>
- Direct Known Subclasses:
ByteHashSet.EntryIterator
,CharHashSet.EntryIterator
,DoubleHashSet.EntryIterator
,FloatHashSet.EntryIterator
,IntHashSet.EntryIterator
,LongHashSet.EntryIterator
,ObjectHashSet.EntryIterator
,ShortHashSet.EntryIterator
public abstract class AbstractIterator<E> extends java.lang.Object implements java.util.Iterator<E>
Simplifies the implementation of iterators a bit. Modeled loosely after Google Guava's API.
-
-
Constructor Summary
Constructors Constructor Description AbstractIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected E
done()
Call when done.protected abstract E
fetch()
Fetch next element.boolean
hasNext()
E
next()
void
remove()
Default implementation throwsUnsupportedOperationException
.
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<E>
-
remove
public void remove()
Default implementation throwsUnsupportedOperationException
.- Specified by:
remove
in interfacejava.util.Iterator<E>
-
fetch
protected abstract E fetch()
Fetch next element. The implementation must returndone()
when all elements have been fetched.- Returns:
- Returns the next value for the iterator or chain-calls
done()
.
-
done
protected final E done()
Call when done.- Returns:
- Returns a unique sentinel value to indicate end-of-iteration.
-
-