MutableIntList
-
Cmn
class MutableIntList : IntList
MutableIntList is a MutableList-like collection for Int values. It allows storing and retrieving the elements without boxing. Immutable access is available through its base class IntList, which has a List-like interface.
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.
Summary
Public constructors |
|
|---|---|
MutableIntList(initialCapacity: Int)Creates a |
Cmn
|
Public functions |
||
|---|---|---|
Boolean |
Adds |
Cmn
|
Unit |
Adds |
Cmn
|
inline Boolean |
Adds all |
Cmn
|
inline Boolean |
Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Unit |
clear()Removes all elements in the |
Cmn
|
Unit |
ensureCapacity(capacity: Int)Ensures that there is enough space to store |
Cmn
|
inline operator Unit |
minusAssign(element: Int)
|
Cmn
|
operator Unit |
minusAssign(elements: IntArray)Removes all |
Cmn
|
operator Unit |
minusAssign(elements: IntList)Removes all |
Cmn
|
inline operator Unit |
plusAssign(element: Int)
|
Cmn
|
inline operator Unit |
plusAssign(elements: IntArray)Adds all |
Cmn
|
inline operator Unit |
plusAssign(elements: IntList)Adds all |
Cmn
|
Boolean |
Removes |
Cmn
|
Boolean |
Removes all |
Cmn
|
Boolean |
Removes all |
Cmn
|
Int |
Removes the element at the given |
Cmn
|
Unit |
removeRange(start: @IntRange(from = 0) Int, end: @IntRange(from = 0) Int)Removes items from index |
Cmn
|
Boolean |
Keeps only |
Cmn
|
Boolean |
Keeps only |
Cmn
|
operator Int |
Cmn
|
|
Unit |
sort()Sorts the |
Cmn
|
Unit |
Sorts the |
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
MutableIntList
MutableIntList(initialCapacity: Int = 16)
Creates a MutableIntList with a capacity of initialCapacity.
Public functions
add
fun add(index: @IntRange(from = 0) Int, element: Int): Unit
Adds element to the MutableIntList at the given index, shifting over any elements at index and after, if any.
addAll
inline fun addAll(elements: IntArray): Boolean
Adds all elements to the end of the MutableIntList and returns true if the MutableIntList was changed or false if elements was empty.
addAll
inline fun addAll(elements: IntList): Boolean
Adds all elements to the end of the MutableIntList and returns true if the MutableIntList was changed or false if elements was empty.
addAll
fun addAll(index: @IntRange(from = 0) Int, elements: IntArray): Boolean
Adds all elements to the MutableIntList 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: IntList): Boolean
Adds all elements to the MutableIntList at the given index, shifting over any elements at index and after, if any.
| Returns | |
|---|---|
Boolean |
|
clear
fun clear(): Unit
Removes all elements in the MutableIntList. The storage isn't released.
| See also | |
|---|---|
trim |
ensureCapacity
fun ensureCapacity(capacity: Int): Unit
Ensures that there is enough space to store capacity elements in the MutableIntList.
| See also | |
|---|---|
trim |
minusAssign
operator fun minusAssign(elements: IntArray): Unit
Removes all elements from the MutableIntList.
minusAssign
operator fun minusAssign(elements: IntList): Unit
Removes all elements from the MutableIntList.
plusAssign
inline operator fun plusAssign(elements: IntArray): Unit
Adds all elements to the end of the MutableIntList.
plusAssign
inline operator fun plusAssign(elements: IntList): Unit
Adds all elements to the end of the MutableIntList.
remove
fun remove(element: Int): Boolean
Removes element from the MutableIntList. If element was in the MutableIntList and was removed, true will be returned, or false will be returned if the element was not found.
removeAll
fun removeAll(elements: IntArray): Boolean
Removes all elements from the MutableIntList and returns true if anything was removed.
removeAll
fun removeAll(elements: IntList): Boolean
Removes all elements from the MutableIntList and returns true if anything was removed.
removeAt
fun removeAt(index: @IntRange(from = 0) Int): Int
Removes the element at the given index and returns it.
removeRange
fun removeRange(start: @IntRange(from = 0) Int, end: @IntRange(from = 0) Int): Unit
Removes items from index start (inclusive) to end (exclusive).
retainAll
fun retainAll(elements: IntArray): Boolean
Keeps only elements in the MutableIntList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: IntList): Boolean
Keeps only elements in the MutableIntList and removes all other values.
| Returns | |
|---|---|
Boolean |
|
set
operator fun set(index: @IntRange(from = 0) Int, element: Int): Int
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 MutableIntList must grow.
| See also | |
|---|---|
ensureCapacity |