ObservableList¶
class ObservableList<T>(list: MutableList<T>, listener: (MutableList<T>) -> Unit) : MutableList<T>
A MutableList wrapper that invokes listener with the underlying list after every mutating operation. Used by listField-style NBTHolder delegates to detect changes and persist/sync them.
Constructors¶
ObservableList¶
constructor(list: MutableList<T>, listener: (MutableList<T>) -> Unit)
Properties¶
size¶
Functions¶
add¶
addAll¶
open override fun addAll(elements: Collection<T>): Boolean
open override fun addAll(index: Int, elements: Collection<T>): Boolean
addFirst¶
addLast¶
clear¶
open override fun clear()
contains¶
containsAll¶
open override fun containsAll(elements: Collection<T>): Boolean
get¶
indexOf¶
isEmpty¶
iterator¶
open operator override fun iterator(): MutableIterator<T>
lastIndexOf¶
open override fun lastIndexOf(element: T): Int
listIterator¶
open override fun listIterator(): MutableListIterator<T>
open override fun listIterator(index: Int): MutableListIterator<T>
remove¶
removeAll¶
open override fun removeAll(elements: Collection<T>): Boolean
removeAt¶
removeFirst¶
open override fun removeFirst(): T
removeIf¶
removeLast¶
open override fun removeLast(): T
replaceAll¶
open override fun replaceAll(operator: UnaryOperator<T>)
retainAll¶
open override fun retainAll(elements: Collection<T>): Boolean
set¶
setAll¶
fun setAll(elements: Collection<T>)
Replaces the whole contents with elements, notifying listener exactly once.
The one bulk write. Every other mutator here notifies per operation, which for a persisted field means a whole-list encode per element touched - so a caller rewriting n entries one at a time pays n encodes of n entries, and the cost of holding a list grows with the square of its length. A caller that already knows the entire next state says so through this instead: copy the list out, work on the copy, hand it back in one call.
sort¶
open override fun sort(c: Comparator<in T>?)
subList¶
open override fun subList(fromIndex: Int, toIndex: Int): MutableList<T>