Class IteratorIterable<T>

  • Type Parameters:
    T - The element type
    All Implemented Interfaces:
    java.lang.Iterable<T>

    public class IteratorIterable<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>
    This is an Iterable that returns a given Iterator. This is useful for using the new for loop syntax when you only have an Iterator.
    Author:
    Matthew Wakeling
    • Constructor Summary

      Constructors 
      Constructor Description
      IteratorIterable​(java.util.Iterator<T> iterator)
      Constructs an Iterable from an Iterator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<T> iterator()
      Returns the iterator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • IteratorIterable

        public IteratorIterable​(java.util.Iterator<T> iterator)
        Constructs an Iterable from an Iterator.
        Parameters:
        iterator - an Iterator
    • Method Detail

      • iterator

        public java.util.Iterator<T> iterator()
        Returns the iterator.
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        an iterator