Class EmptyIterator<T>

  • Type Parameters:
    T - formal type of objects to iterate
    All Implemented Interfaces:
    java.util.Iterator<T>

    public final class EmptyIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>

    An empty Iterator that iterates through no elements.

    Use getInstance() to get an instance.

    This instance can be used in several threads concurrently.

    Author:
    agz
    • Method Detail

      • getInstance

        public static <T> EmptyIterator<T> getInstance()
        Returns an instance of EmptyIterator.
        Type Parameters:
        T - formal type of objects to iterate
        Returns:
        an instance of EmptyIterator
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object