Package io.github.jmcleodfoss.pst
Class EmptyIterator
java.lang.Object
io.github.jmcleodfoss.pst.EmptyIterator
public class EmptyIterator extends Object implements Iterator<Object>
The EmptyIterator class is an iterator for empty lists. It is useful in some circumstances when one wishes to avoid checking
for null in client code.
-
Field Summary
Fields Modifier and Type Field Description static EmptyIterator
iterator
A generic EmptyIterator object which may be used by anyone, and has no state, so it can be shared. -
Constructor Summary
Constructors Constructor Description EmptyIterator()
-
Method Summary
-
Field Details
-
iterator
A generic EmptyIterator object which may be used by anyone, and has no state, so it can be shared.
-
-
Constructor Details
-
EmptyIterator
public EmptyIterator()
-
-
Method Details
-
hasNext
public boolean hasNext()Are there any more elements to return? Note that there are never any more elements in an EmptyIterator. return false, always (the EmptyIterator never contains any elements, by definition. -
next
Get the next element. This function should never be called (since hasNext always returns true). In fact, calling this function is a programming error, and the UnsupportedOperationExcpetion will be thrown. returns Nothing - calling this function results in an exception being thrown. -
remove
public void remove()The remove function is not supported by the EmptyIterator iterator.
-