Skip to content

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.

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.

ReturnsSignatureSummary
IndexedList<E>linked() factoryCreates a list for one thread.
IndexedList<E>concurrent() factoryCreates a list that several threads can read while one changes it: each change copies the list.

ReturnsSignatureSummary
voidadd(E element)Adds element at its place; an element already in the list is not added twice.
voidremove(E element)Removes element.
voidclear()Removes every element.
intsize()Returns the number of elements.
booleanisEmpty()If true, the list holds no element.
booleancontains(E element)If true, the list holds element.
EgetFirst()Returns the element of the lowest index, or null when the list is empty.
EgetLast()Returns the element of the highest index, or null when the list is empty.
Eget(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.

<E extends IIndexedElement> IndexedList<E> linked() factory

Creates a list for one thread.

<E extends IIndexedElement> IndexedList<E> concurrent() factory

Creates a list that several threads can read while one changes it: each change copies the list.

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.


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

Report a problem with this page