MutableObjectList
-
Cmn
class MutableObjectList<E : Any?> : ObjectList
MutableObjectList is a MutableList-like collection for reference types. It is optimized for fast access, avoiding virtual and interface method access. Methods avoid allocation whenever possible. For example forEach does not need allocate an Iterator.
This implementation is not thread-safe: if multiple threads access this container concurrently, and one or more threads modify the structure of the list (insertion or removal for instance), the calling code must provide the appropriate synchronization. It is also not safe to mutate during reentrancy -- in the middle of a forEach, for example. However, concurrent reads are safe.
Note List access is available through asList when developers need access to the common API.
Note MutableList access is available through asMutableList when developers need access to the common API.
It is best to use this for all internal implementations where a list of reference types is needed. Use MutableList in public API to take advantage of the commonly-used interface. It is common to use MutableObjectList internally and use asMutableList or asList to get a MutableList or List interface for interacting with public APIs.
MutableLongList
| See also | |
|---|---|
ObjectList |
|
MutableFloatList |
|
MutableIntList |
Summary
Public constructors |
|
|---|---|
<E : Any?> MutableObjectList(initialCapacity: Int) |
Cmn
|
Public functions |
||
|---|---|---|
Boolean |
add(element: E)Adds |
Cmn
|
Unit |
Adds |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
addAll(elements: ObjectList<E>)Adds all |
Cmn
|
Boolean |
addAll(elements: ScatterSet<E>)Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
addAll(index: @IntRange(from = 0) Int, elements: Collection<E>)Adds all |
Cmn
|
Boolean |
addAll(index: @IntRange(from = 0) Int, elements: ObjectList<E>)Adds all |
Cmn
|
open List<E> |
asList()Returns a |
Cmn
|
MutableList<E> |
Returns a |
Cmn
|
Unit |
clear()Removes all elements in the |
Cmn
|
inline Unit |
ensureCapacity(capacity: Int)Ensures that there is enough space to store |
Cmn
|
inline operator Unit |
minusAssign(element: E)
|
Cmn
|
operator Unit |
minusAssign(elements: Array<E>)Removes all |
Cmn
|
operator Unit |
minusAssign(elements: Iterable<E>)Removes all |
Cmn
|
operator Unit |
minusAssign(elements: List<E>)Removes all |
Cmn
|
operator Unit |
minusAssign(elements: ObjectList<E>)Removes all |
Cmn
|
operator Unit |
minusAssign(elements: ScatterSet<E>)Removes all |
Cmn
|
operator Unit |
minusAssign(elements: Sequence<E>)Removes all |
Cmn
|
inline operator Unit |
plusAssign(element: E)
|
Cmn
|
operator Unit |
plusAssign(elements: Array<E>)Adds all |
Cmn
|
operator Unit |
plusAssign(elements: Iterable<E>)Adds all |
Cmn
|
operator Unit |
plusAssign(elements: List<E>)Adds all |
Cmn
|
operator Unit |
plusAssign(elements: ObjectList<E>)Adds all |
Cmn
|
operator Unit |
plusAssign(elements: ScatterSet<E>)Adds all |
Cmn
|
operator Unit |
plusAssign(elements: Sequence<E>)Adds all |
Cmn
|
Boolean |
remove(element: E)Removes |
Cmn
|
Boolean |
Removes all |
Cmn
|
Boolean |
Removes all |
Cmn
|
Boolean |
Removes all |
Cmn
|
Boolean |
removeAll(elements: ObjectList<E>)Removes all |
Cmn
|
Boolean |
removeAll(elements: ScatterSet<E>)Removes all |
Cmn
|
Boolean |
Removes all |
Cmn
|
E |
Removes the element at the given |
Cmn
|
inline Unit |
Removes all elements in this list for which |
Cmn
|
Unit |
removeRange(start: @IntRange(from = 0) Int, end: @IntRange(from = 0) Int)Removes elements from index |
Cmn
|
Boolean |
Keeps only |
Cmn
|
Boolean |
retainAll(elements: Collection<E>)Keeps only |
Cmn
|
Boolean |
Keeps only |
Cmn
|
Boolean |
retainAll(elements: ObjectList<E>)Keeps only |
Cmn
|
Boolean |
Keeps only |
Cmn
|
operator E |
Cmn
|
|
Unit |
Reduces the internal storage. |
Cmn
|
Public properties |
||
|---|---|---|
Int |
Returns the total number of elements that can be held before the |
Cmn
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public functions
add
fun add(index: @IntRange(from = 0) Int, element: E): Unit
Adds element to the MutableObjectList at the given index, shifting over any elements at index and after, if any.
addAll
fun addAll(elements: Array<E>): Boolean
Adds all elements to the end of the MutableObjectList and returns true if the MutableObjectList was changed or false if elements was empty.
addAll
fun addAll(elements: Iterable<E>): Boolean
Adds all elements to the end of the MutableObjectList and returns true if the MutableObjectList was changed or false if elements was empty.
addAll
fun addAll(elements: List<E>): Boolean
Adds all elements to the end of the MutableObjectList and returns true if the MutableObjectList was changed or false if elements was empty.
addAll
fun addAll(elements: ObjectList<E>): Boolean
Adds all elements to the end of the MutableObjectList and returns true if the MutableObjectList was changed or false if elements was empty.
addAll
fun addAll(elements: ScatterSet<E>): Boolean
Adds all elements to the end of the MutableObjectList and returns true if the MutableObjectList was changed or false if elements was empty.
addAll
fun addAll(elements: Sequence<E>): Boolean
Adds all elements to the end of the MutableObjectList and returns true if the MutableObjectList was changed or false if elements was empty.
addAll
fun addAll(index: @IntRange(from = 0) Int, elements: Array<E>): Boolean
Adds all elements to the MutableObjectList at the given index, shifting over any elements at index and after, if any.
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(index: @IntRange(from = 0) Int, elements: Collection<E>): Boolean
Adds all elements to the MutableObjectList at the given index, shifting over any elements at index and after, if any.
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(index: @IntRange(from = 0) Int, elements: ObjectList<E>): Boolean
Adds all elements to the MutableObjectList at the given index, shifting over any elements at index and after, if any.
| Returns | |
|---|---|
Boolean |
|
asList
open fun asList(): List<E>
Returns a List view into the ObjectList. All access to the collection will be less efficient and abides by the allocation requirements of the List. For example, List.forEach will allocate an iterator. All access will go through the more expensive interface calls. Critical performance areas should use the ObjectList API rather than List API, when possible.
asMutableList
fun asMutableList(): MutableList<E>
Returns a MutableList view into the MutableObjectList. All access to the collection will be less efficient and abides by the allocation requirements of the MutableList. For example, MutableList.forEach will allocate an iterator. All access will go through the more expensive interface calls. Critical performance areas should use the MutableObjectList API rather than MutableList API, when possible.
clear
fun clear(): Unit
Removes all elements in the MutableObjectList. The storage isn't released.
| See also | |
|---|---|
trim |
ensureCapacity
inline fun ensureCapacity(capacity: Int): Unit
Ensures that there is enough space to store capacity elements in the MutableObjectList.
| See also | |
|---|---|
trim |
minusAssign
operator fun minusAssign(elements: Array<E>): Unit
Removes all elements from the MutableObjectList.
minusAssign
operator fun minusAssign(elements: Iterable<E>): Unit
Removes all elements from the MutableObjectList.
minusAssign
operator fun minusAssign(elements: List<E>): Unit
Removes all elements from the MutableObjectList.
minusAssign
operator fun minusAssign(elements: ObjectList<E>): Unit
Removes all elements from the MutableObjectList.
minusAssign
operator fun minusAssign(elements: ScatterSet<E>): Unit
Removes all elements from the MutableObjectList.
minusAssign
operator fun minusAssign(elements: Sequence<E>): Unit
Removes all elements from the MutableObjectList.
plusAssign
operator fun plusAssign(elements: Array<E>): Unit
Adds all elements to the end of the MutableObjectList.
plusAssign
operator fun plusAssign(elements: Iterable<E>): Unit
Adds all elements to the end of the MutableObjectList.
plusAssign
operator fun plusAssign(elements: List<E>): Unit
Adds all elements to the end of the MutableObjectList.
plusAssign
operator fun plusAssign(elements: ObjectList<E>): Unit
Adds all elements to the end of the MutableObjectList.
plusAssign
operator fun plusAssign(elements: ScatterSet<E>): Unit
Adds all elements to the end of the MutableObjectList.
plusAssign
operator fun plusAssign(elements: Sequence<E>): Unit
Adds all elements to the end of the MutableObjectList.
remove
fun remove(element: E): Boolean
Removes element from the MutableObjectList. If element was in the MutableObjectList and was removed, true will be returned, or false will be returned if the element was not found.
removeAll
fun removeAll(elements: Array<E>): Boolean
Removes all elements from the MutableObjectList and returns true if anything was removed.
removeAll
fun removeAll(elements: Iterable<E>): Boolean
Removes all elements from the MutableObjectList and returns true if anything was removed.
removeAll
fun removeAll(elements: List<E>): Boolean
Removes all elements from the MutableObjectList and returns true if anything was removed.
removeAll
fun removeAll(elements: ObjectList<E>): Boolean
Removes all elements from the MutableObjectList and returns true if anything was removed.
removeAll
fun removeAll(elements: ScatterSet<E>): Boolean
Removes all elements from the MutableObjectList and returns true if anything was removed.
removeAll
fun removeAll(elements: Sequence<E>): Boolean
Removes all elements from the MutableObjectList and returns true if anything was removed.
removeAt
fun removeAt(index: @IntRange(from = 0) Int): E
Removes the element at the given index and returns it.
removeIf
inline fun removeIf(predicate: (element) -> Boolean): Unit
Removes all elements in this list for which predicate returns true.
removeRange
fun removeRange(start: @IntRange(from = 0) Int, end: @IntRange(from = 0) Int): Unit
Removes elements from index start (inclusive) to end (exclusive).
retainAll
fun retainAll(elements: Array<E>): Boolean
Keeps only elements in the MutableObjectList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: Collection<E>): Boolean
Keeps only elements in the MutableObjectList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: Iterable<E>): Boolean
Keeps only elements in the MutableObjectList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: ObjectList<E>): Boolean
Keeps only elements in the MutableObjectList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: Sequence<E>): Boolean
Keeps only elements in the MutableObjectList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
set
operator fun set(index: @IntRange(from = 0) Int, element: E): E
Sets the value at index to element.
| Returns | |
|---|---|
E |
the previous value set at |
trim
fun trim(minCapacity: Int = _size): Unit
Reduces the internal storage. If capacity is greater than minCapacity and size, the internal storage is reduced to the maximum of size and minCapacity.
| See also | |
|---|---|
ensureCapacity |
Public properties
capacity
val capacity: Int
Returns the total number of elements that can be held before the MutableObjectList must grow.
| See also | |
|---|---|
ensureCapacity |