Class FutureIterator<T>

java.lang.Object
com.github.basking2.sdsai.itrex.iterators.FutureIterator<T>
All Implemented Interfaces:
Iterator<Future<T>>

public class FutureIterator<T> extends Object implements Iterator<Future<T>>
A class that wraps an iterator such that calls to next() result in a Future being returned. The wrapped iterator must be thread-safe.
  • Constructor Details

    • FutureIterator

      public FutureIterator(Iterator<T> iterator, Executor executor)
      Create a new FutureIterator.
      Parameters:
      iterator - A thread-safe iterator.
      executor - The executor Futures will be completed in.
  • Method Details

    • hasNext

      public boolean hasNext()
      Return true if there are more elements in the source iterator. This call is not reliable as a call to Iterator.next() may be happening as this call returns.
      Specified by:
      hasNext in interface Iterator<T>
      Returns:
      true if, at the moment Iterator.hasNext() is called on the wrapped iterator, it returns true. False otherwise.
    • next

      public Future<T> next()
      Specified by:
      next in interface Iterator<T>