Class ObjectIterator<E>

java.lang.Object
com.globalmentor.collections.iterators.ObjectIterator<E>
Type Parameters:
E - The type of elements in this iterator
All Implemented Interfaces:
Iterable<E>, Iterator<E>
Direct Known Subclasses:
ObjectListIterator

public class ObjectIterator<E> extends Object implements Iterator<E>, Iterable<E>
An iterable and iterator to a single object. This implementation allows null values. This implementation does not allow removal, as removing has no meaning in this context. This version releases the object when iteration has occurred (i.e. when hasNext() would return false).
Author:
Garret Wilson
  • Field Details

    • object

      protected E object
      The single object being iterated.
    • hasNext

      protected boolean hasNext
      Whether we've not retrieved the object.
  • Constructor Details

    • ObjectIterator

      public ObjectIterator(E object)
      Object constructor.
      Parameters:
      object - The single object over which iteration should occur.
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E>
    • next

      public E next()
      Specified by:
      next in interface Iterator<E>
    • remove

      public void remove()
      This implementation does not support removal.
      Specified by:
      remove in interface Iterator<E>
    • iterator

      public Iterator<E> iterator()
      This implementation returns this.
      Specified by:
      iterator in interface Iterable<E>