E - the element typepublic interface Cycle<E>
| Modifier and Type | Method and Description |
|---|---|
Cycle<E> |
copy()
Creates a copy of this cycle.
|
E |
current()
Gets the current element
|
int |
cursor()
Gets the current position of the cursor, as as index relating to a
position in the backing list.
|
List<E> |
getBacking()
Gets the list currently backing this cycle
|
E |
next()
Advances the cursor, and returns the next element.
|
int |
nextPosition()
Returns the index of the next position in the cycle.
|
static <E> Cycle<E> |
of(List<E> objects)
Creates a new cycle of elements.
|
E |
peekNext()
Returns the next element without advancing the cursor.
|
E |
peekPrevious()
Returns the previous element without retreating the cursor.
|
E |
previous()
Retreats the counter, and returns the previous element.
|
int |
previousPosition()
Returns the index of the previous position in the cycle.
|
void |
setCursor(int index)
Sets the cursor to a given index
|
@Nonnull static <E> Cycle<E> of(@Nonnull List<E> objects)
Changes to the supplying list are not reflected in the cycle.
E - the element typeobjects - the objects to form the cycle fromint cursor()
void setCursor(int index)
index - the index to set the cursor toIndexOutOfBoundsException - if the index is out of bounds@Nonnull E previous()
int nextPosition()
int previousPosition()
@Nonnull E peekNext()
@Nonnull E peekPrevious()
@Nonnull List<E> getBacking()
The returned list is immutable.
Copyright © 2022. All rights reserved.