Class TimeLimitIteration<E,X extends Exception>

All Implemented Interfaces:
AutoCloseable, CloseableIteration<E,X>, Iteration<E,X>
Direct Known Subclasses:
AbstractParserQuery.QueryInterruptIteration, AbstractParserQuery.QueryInterruptIteration

public abstract class TimeLimitIteration<E,X extends Exception> extends IterationWrapper<E,X>
Author:
Arjohn Kampman
  • Constructor Details

    • TimeLimitIteration

      protected TimeLimitIteration(Iteration<? extends E,? extends X> iter, long timeLimit)
  • Method Details

    • hasNext

      public boolean hasNext() throws X
      Description copied from class: IterationWrapper
      Checks whether the wrapped Iteration contains more elements, closing this Iteration when this is not the case.
      Specified by:
      hasNext in interface Iteration<E,X extends Exception>
      Overrides:
      hasNext in class IterationWrapper<E,X extends Exception>
      Returns:
      true if the wrapped Iteration contains more elements, false otherwise.
      Throws:
      X
    • next

      public E next() throws X
      Description copied from class: IterationWrapper
      Returns the next element from the wrapped Iteration.
      Specified by:
      next in interface Iteration<E,X extends Exception>
      Overrides:
      next in class IterationWrapper<E,X extends Exception>
      Returns:
      the next element in the iteration.
      Throws:
      X extends Exception
    • remove

      public void remove() throws X
      Description copied from class: IterationWrapper
      Removes the last element that has been returned from the wrapped Iteration.
      Specified by:
      remove in interface Iteration<E,X extends Exception>
      Overrides:
      remove in class IterationWrapper<E,X extends Exception>
      Throws:
      X extends Exception
    • handleClose

      protected void handleClose() throws X
      Description copied from class: IterationWrapper
      Closes this Iteration and also closes the wrapped Iteration if it is a CloseableIteration.
      Overrides:
      handleClose in class IterationWrapper<E,X extends Exception>
      Throws:
      X
    • throwInterruptedException

      protected abstract void throwInterruptedException() throws X
      If the iteration is interrupted by its time limit, this method is called to generate and throw the appropriate exception.
      Throws:
      X - The generic class of exceptions thrown by this method.