IndexedList
final class IndexedList<E extends IIndexedElement>
Implements: Iterable<E>
Package: dev.joid.lib.utils.list · Module: core · Source: IndexedList.java
List kept sorted by the index of its elements, with equal indexes in insertion order.
Description
Section titled “Description”The children of a node and the UIs of a bridge live in one, sorted by their zindex.
When the index of an element changes, the list sorts itself again at the next read.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
IndexedList<E> | linked() factory | Creates a list for one thread. |
IndexedList<E> | concurrent() factory | Creates a list that several threads can read while one changes it: each change copies the list. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | add(E element) | Adds element at its place; an element already in the list is not added twice. |
void | remove(E element) | Removes element. |
void | clear() | Removes every element. |
int | size() | Returns the number of elements. |
boolean | isEmpty() | If true, the list holds no element. |
boolean | contains(E element) | If true, the list holds element. |
E | getFirst() | Returns the element of the lowest index, or null when the list is empty. |
E | getLast() | Returns the element of the highest index, or null when the list is empty. |
E | get(int index) | Returns the element at position index in the sorted order; throws an IndexOutOfBoundsException outside the list. |
List<E> | ordered() | Returns a read-only view of the elements from the lowest index to the highest; the view follows the changes of the list. |
List<E> | reversed() | Returns a read-only view of the elements from the highest index to the lowest; the view follows the changes of the list. |
Iterator<E> | iterator() | Iterates over the elements from the lowest index to the highest. |
Creation details
Section titled “Creation details”linked
Section titled “linked”<E extends IIndexedElement> IndexedList<E> linked() factory
Creates a list for one thread.
concurrent
Section titled “concurrent”<E extends IIndexedElement> IndexedList<E> concurrent() factory
Creates a list that several threads can read while one changes it: each change copies the list.
Method details
Section titled “Method details”void add(E element)
Adds element at its place; an element already in the list is not added twice.
remove
Section titled “remove”void remove(E element)
Removes element.
void clear()
Removes every element.
int size()
Returns the number of elements.
isEmpty
Section titled “isEmpty”boolean isEmpty()
If true, the list holds no element.
contains
Section titled “contains”boolean contains(E element)
If true, the list holds element.
getFirst
Section titled “getFirst”E getFirst()
Returns the element of the lowest index, or null when the list is empty.
getLast
Section titled “getLast”E getLast()
Returns the element of the highest index, or null when the list is empty.
E get(int index)
Returns the element at position index in the sorted order; throws an IndexOutOfBoundsException outside the list.
ordered
Section titled “ordered”List<E> ordered()
Returns a read-only view of the elements from the lowest index to the highest; the view follows the changes of the list.
reversed
Section titled “reversed”List<E> reversed()
Returns a read-only view of the elements from the highest index to the lowest; the view follows the changes of the list.
iterator
Section titled “iterator”Iterator<E> iterator()
Iterates over the elements from the lowest index to the highest.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
