Class IterableSequence<T>

Type Parameters:
T - the type of the elements in the iterable

public class IterableSequence<T> extends ForwardOnlySequence<T>
A sequence that loops over an iterable and can only go forward.
  • Constructor Details

    • IterableSequence

      public IterableSequence(Iterable<T> iterable)
      Creates a new sequence for the given iterable.
      Parameters:
      iterable - the iterable to loop over
  • Method Details

    • loop

      public <R> R loop(BiConsumer<Integer,T> consumer)
      Executes the given consumer for each element in the loop.

      If the iterable provided to the constructor was null, this method will do nothing.

      Specified by:
      loop in class ForwardOnlySequence<T>
      Type Parameters:
      R - the type of the return value
      Parameters:
      consumer - the consumer to execute for each element
      Returns:
      the value passed to Loop._break_(Object...), or null if the loop completes without a _break_