Package ste.lloop

Class AbstractSequence<S extends AbstractSequence<S>>

java.lang.Object
ste.lloop.AbstractSequence<S>
Type Parameters:
S - the type of the sequence
Direct Known Subclasses:
ForwardOnlySequence, IndexedSequence, MapSequence

public abstract class AbstractSequence<S extends AbstractSequence<S>> extends Object
A base class for sequences that can be iterated over with indexes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final NumericSequence
    The numeric series that controls the looping.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new collection sequence.
  • Method Summary

    Modifier and Type
    Method
    Description
    from(int from)
    Sets the starting index of the loop (inclusive).
    step(int step)
    Sets the step of the loop.
    to(int to)
    Sets the ending index of the loop (inclusive).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • indexes

      protected final NumericSequence indexes
      The numeric series that controls the looping.
  • Constructor Details

    • AbstractSequence

      public AbstractSequence()
      Creates a new collection sequence.
  • Method Details

    • step

      public S step(int step)
      Sets the step of the loop. The sign of the step determines the direction of the loop.

      If the step is positive, the loop will go from from to to. If the step is negative, the loop will go from to to from.

      The absolute value of the step is used as the increment. If the step is zero, the loop will not execute.

      Parameters:
      step - the step value
      Returns:
      this instance
    • from

      public S from(int from)
      Sets the starting index of the loop (inclusive).
      Parameters:
      from - the starting index
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if 'from' is less than zero
    • to

      public S to(int to)
      Sets the ending index of the loop (inclusive).
      Parameters:
      to - the ending index
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if 'to' is less than zero