Package ste.lloop
Class ForwardOnlySequence<T>
- Type Parameters:
T- the type of the elements in the iterable
A sequence that loops over an iterable and can only go forward.
-
Field Summary
Fields inherited from class ste.lloop.AbstractSequence
indexes -
Constructor Summary
ConstructorsConstructorDescriptionForwardOnlySequence(Iterable<T> iterable) Creates a new sequence for the given iterable. -
Method Summary
Modifier and TypeMethodDescriptionfrom(int from) Sets the starting index of the loop (inclusive).<R> Rloop(BiConsumer<Integer, T> consumer) Executes 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
Creates a new sequence for the given iterable.- Parameters:
iterable- the iterable to loop over
-
-
Method Details
-
to
Description copied from class:AbstractSequenceSets the ending index of the loop (inclusive).- Overrides:
toin classAbstractSequence<ForwardOnlySequence<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>>- 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>>- Parameters:
step- the step value- Returns:
- this instance
-
loop
Executes the given consumer for each element in the loop.If the iterable 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.brk(Object), ornullif the loop completes without abrk
-