Class ForwardOnlySequence<T>
- Type Parameters:
T- the type of the elements in the sequence
- Direct Known Subclasses:
IterableSequence,IteratorSequence,LinesSequence
A sequence that loops only forwards
-
Field Summary
Fields inherited from class ste.lloop.AbstractSequence
indexes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfrom(int from) Sets the starting index of the loop (inclusive).abstract <R> Rloop(BiConsumer<Integer, T> consumer) Executes the given consumer for each element in the loop.<R> RExecutes the given consumer for each element in the loop.step(int step) Sets the step of the loop.to(int to) Sets the ending index of the loop (inclusive).
-
Constructor Details
-
ForwardOnlySequence
protected ForwardOnlySequence()Constructs a newForwardOnlySequenceinstance.
-
-
Method Details
-
to
Description copied from class:AbstractSequenceSets the ending index of the loop (inclusive).- Overrides:
toin classAbstractSequence<ForwardOnlySequence<T>, T>- Parameters:
to- the ending index- Returns:
- this instance
-
from
Description copied from class:AbstractSequenceSets the starting index of the loop (inclusive).- Overrides:
fromin classAbstractSequence<ForwardOnlySequence<T>, T>- Parameters:
from- the starting index- Returns:
- this instance
-
step
Description copied from class:AbstractSequenceSets 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
fromtoto. If the step is negative, the loop will go fromtotofrom.The absolute value of the step is used as the increment. If the step is zero, the loop will not execute.
- Overrides:
stepin classAbstractSequence<ForwardOnlySequence<T>, T>- Parameters:
step- the step value- Returns:
- this instance
-
loop
Executes the given consumer for each element in the loop.If the array provided to the constructor was
null, this method will do nothing.- 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...), ornullif the loop completes without a_break_
-
loop
Executes the given consumer for each element in the loop.If the array provided to the constructor was
null, this method will do nothing.- 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...), ornullif the loop completes without a_break_
-