V - item typepublic abstract static class BasicLoop.Item<V extends BasicLoop.Item<V>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
(package private) BasicLoop<V> |
loop
Loop containing this item.
|
(package private) V |
next
Next item in the loop (possibly
this). |
(package private) V |
previous
Previous item in the loop (possibly
this). |
| Modifier | Constructor and Description |
|---|---|
protected |
Item(BasicLoop<V> loop)
Constructor for first item.
|
protected |
Item(BasicLoop<V> loop,
V previous,
V next)
Standard constructor..
|
| Modifier and Type | Method and Description |
|---|---|
V |
advanced(int steps)
Advance to the item
steps steps away. |
V |
exchangeWith(Function3<? extends V,BasicLoop<V>,V,V> creator)
Exchange this item with a new item.
|
V |
findNext(java.util.function.Predicate<? super V> condition)
Find the next item for which its value fulfills the given condition, starting with this item.
|
V |
findPrevious(java.util.function.Predicate<? super V> condition)
Find the previous item for which its value fulfills the given condition, starting with this item.
|
BasicLoop<V> |
getLoop()
Get the loop to which this item belongs.
|
V |
getNext()
Get the next item.
|
V |
getPrevious()
Get the previous item.
|
V |
insertAfter(Function3<? extends V,BasicLoop<V>,V,V> creator)
Insert an item after this one.
|
V |
insertBefore(Function3<? extends V,BasicLoop<V>,V,V> creator)
Insert an item before this one.
|
boolean |
isValid()
Does this item still belong to a loop.
|
(package private) java.util.Iterator<V> |
iteratorTo(V otherItem) |
int |
minStepsTo(V otherItem)
Get the number of steps from this item to another item.
|
void |
remove()
Remove this item from the loop.
|
int |
stepsTo(V otherItem)
Get the number of steps from this item to another item.
|
void |
swapPlaces(V item)
Exchange the loop position of this item with the one of the given item
and vice versa.
|
@Nullable BasicLoop<V extends BasicLoop.Item<V>> loop
null if this item is removed.@NotNull V extends BasicLoop.Item<V> previous
this).@NotNull V extends BasicLoop.Item<V> next
this).protected Item(@NotNull BasicLoop<V> loop, @Nullable V previous, @Nullable V next)
loop - loop to which this item belongsprevious - previous itemnext - next itempublic V advanced(int steps)
steps steps away.steps - steps to advance, forward if positive, backward if negativepublic int stepsTo(@NotNull V otherItem)
otherItem - another item which has to be in the same loop as this item0 or positiveminStepsTo(BasicLoop.Item)public int minStepsTo(@NotNull V otherItem)
otherItem - other item which has to be in the same loop as this item@Nullable public BasicLoop<V> getLoop()
null if this item is removed from its looppublic boolean isValid()
true if it belongs to a loopfalse if it is already removed@NotNull public V insertBefore(Function3<? extends V,BasicLoop<V>,V,V> creator)
creator - item creator@NotNull public V insertAfter(Function3<? extends V,BasicLoop<V>,V,V> creator)
creator - item creatorpublic void swapPlaces(@NotNull V item)
Note that this method also allows to exchange items between different loops and even removed items.
item - item which will exchange its chaining properties with this onepublic V exchangeWith(@NotNull Function3<? extends V,BasicLoop<V>,V,V> creator)
Note that this item is removed and invalid after the call.
creator - creator for new itempublic void remove()
@Nullable public V findNext(@NotNull java.util.function.Predicate<? super V> condition)
condition - condition to be checkednull if no item matches the condition@Nullable public V findPrevious(@NotNull java.util.function.Predicate<? super V> condition)
condition - condition to be checkednull if no item matches the condition