MutableVector
-
Cmn
class MutableVector<T : Any?>
A MutableList-like structure with a simplified interface that offers faster access than ArrayList.
Summary
Public functions |
||
|---|---|---|
Boolean |
add(element: T)Adds |
Cmn
|
Unit |
Adds |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
addAll(elements: Collection<T>)Adds all |
Cmn
|
inline Boolean |
Adds all |
Cmn
|
inline Boolean |
addAll(elements: MutableVector<T>)Adds all |
Cmn
|
Boolean |
addAll(index: Int, elements: Collection<T>)Adds all |
Cmn
|
Boolean |
Adds all |
Cmn
|
Boolean |
addAll(index: Int, elements: MutableVector<T>)Adds all |
Cmn
|
inline Boolean |
Returns |
Cmn
|
MutableList<T> |
Returns |
Cmn
|
Unit |
clear()Removes all elements in the |
Cmn
|
operator Boolean |
contains(element: T)Returns |
Cmn
|
Boolean |
containsAll(elements: Collection<T>)Returns |
Cmn
|
Boolean |
containsAll(elements: List<T>)Returns |
Cmn
|
Boolean |
containsAll(elements: MutableVector<T>)Returns |
Cmn
|
Boolean |
contentEquals(other: MutableVector<T>)Returns |
Cmn
|
inline Unit |
ensureCapacity(capacity: Int)Ensures that there is enough space to store |
Cmn
|
T |
first()Returns the first element in the |
Cmn
|
inline T |
Returns the first element in the |
Cmn
|
inline T? |
Returns the first element in the |
Cmn
|
inline T? |
firstOrNull(predicate: (T) -> Boolean)Returns the first element in the |
Cmn
|
inline R |
Accumulates values, starting with |
Cmn
|
inline R |
<R : Any?> foldIndexed(initial: R, operation: (index: Int, acc, T) -> R)Accumulates values, starting with |
Cmn
|
inline R |
Accumulates values, starting with |
Cmn
|
inline R |
<R : Any?> foldRightIndexed(initial: R, operation: (index: Int, T, acc) -> R)Accumulates values, starting with |
Cmn
|
inline Unit |
Calls |
Cmn
|
inline Unit |
forEachIndexed(block: (Int, T) -> Unit)Calls |
Cmn
|
inline Unit |
forEachReversed(block: (T) -> Unit)Calls |
Cmn
|
inline Unit |
forEachReversedIndexed(block: (Int, T) -> Unit)Calls |
Cmn
|
inline operator T |
Returns the element at the given |
Cmn
|
Int |
indexOf(element: T)Returns the index of |
Cmn
|
inline Int |
indexOfFirst(predicate: (T) -> Boolean)Returns the index if the first element in the |
Cmn
|
inline Int |
indexOfLast(predicate: (T) -> Boolean)Returns the index if the last element in the |
Cmn
|
inline Boolean |
isEmpty()Returns |
Cmn
|
inline Boolean |
Returns |
Cmn
|
T |
last()Returns the last element in the |
Cmn
|
inline T |
Returns the last element in the |
Cmn
|
Int |
lastIndexOf(element: T)Returns the index of the last element in the |
Cmn
|
inline T? |
Returns the last element in the |
Cmn
|
inline T? |
lastOrNull(predicate: (T) -> Boolean)Returns the last element in the |
Cmn
|
inline Array<R> |
Returns an |
Cmn
|
inline Array<R> |
<R : Any?> mapIndexed(transform: (index: Int, T) -> R)Returns an |
Cmn
|
inline MutableVector<R> |
<R : Any?> mapIndexedNotNull(transform: (index: Int, T) -> R?)Returns an |
Cmn
|
inline MutableVector<R> |
<R : Any?> mapNotNull(transform: (T) -> R?)Returns an |
Cmn
|
inline operator Unit |
minusAssign(element: T)
|
Cmn
|
inline operator Unit |
plusAssign(element: T)
|
Cmn
|
Boolean |
remove(element: T)Removes |
Cmn
|
Boolean |
removeAll(elements: Collection<T>)Removes all |
Cmn
|
Boolean |
Removes all |
Cmn
|
Boolean |
removeAll(elements: MutableVector<T>)Removes all |
Cmn
|
T |
Removes the element at the given |
Cmn
|
inline Unit |
Removes items that satisfy |
Cmn
|
Unit |
removeRange(start: Int, end: Int)Removes items from index |
Cmn
|
Boolean |
retainAll(elements: Collection<T>)Keeps only |
Cmn
|
inline Boolean |
reversedAny(predicate: (T) -> Boolean)Returns |
Cmn
|
operator T |
Cmn
|
|
Unit |
sortWith(comparator: Comparator<T>)Sorts the |
Cmn
|
inline Int |
Returns the sum of all values produced by |
Cmn
|
Public properties |
||
|---|---|---|
IntRange |
Returns an |
Cmn
|
Int |
Returns the last valid index in the |
Cmn
|
Int |
The number of elements in the |
Cmn
|
Public functions
add
fun add(index: Int, element: T): Unit
Adds element to the MutableVector at the given index, shifting over any elements that are in the way.
addAll
fun addAll(elements: Array<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
addAll
fun addAll(elements: Collection<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
addAll
inline fun addAll(elements: List<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
addAll
inline fun addAll(elements: MutableVector<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
addAll
fun addAll(index: Int, elements: Collection<T>): Boolean
Adds all elements to the MutableVector at the given index, shifting over any elements that are in the way.
addAll
fun addAll(index: Int, elements: List<T>): Boolean
Adds all elements to the MutableVector at the given index, shifting over any elements that are in the way.
addAll
fun addAll(index: Int, elements: MutableVector<T>): Boolean
Adds all elements to the MutableVector at the given index, shifting over any elements that are in the way.
any
inline fun any(predicate: (T) -> Boolean): Boolean
Returns true if any of the elements give a true return value for predicate.
asMutableList
fun asMutableList(): MutableList<T>
Returns MutableList interface access to the MutableVector.
contains
operator fun contains(element: T): Boolean
Returns true if the MutableVector contains element or false otherwise.
containsAll
fun containsAll(elements: Collection<T>): Boolean
Returns true if the MutableVector contains all elements in elements or false if one or more are missing.
containsAll
fun containsAll(elements: List<T>): Boolean
Returns true if the MutableVector contains all elements in elements or false if one or more are missing.
containsAll
fun containsAll(elements: MutableVector<T>): Boolean
Returns true if the MutableVector contains all elements in elements or false if one or more are missing.
contentEquals
fun contentEquals(other: MutableVector<T>): Boolean
Returns true if the contents of the MutableVector are the same or false if there is any difference. This uses equality comparisons on each element rather than reference equality.
ensureCapacity
inline fun ensureCapacity(capacity: Int): Unit
Ensures that there is enough space to store capacity elements in the MutableVector.
first
fun first(): T
Returns the first element in the MutableVector or throws a NoSuchElementException if it isEmpty.
first
inline fun first(predicate: (T) -> Boolean): T
Returns the first element in the MutableVector for which predicate returns true or throws NoSuchElementException if nothing matches.
firstOrNull
inline fun firstOrNull(): T?
Returns the first element in the MutableVector or null if it isEmpty.
firstOrNull
inline fun firstOrNull(predicate: (T) -> Boolean): T?
Returns the first element in the MutableVector for which predicate returns true or returns null if nothing matches.
fold
inline fun <R : Any?> fold(initial: R, operation: (acc, T) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in order.
foldIndexed
inline fun <R : Any?> foldIndexed(initial: R, operation: (index: Int, acc, T) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in order.
foldRight
inline fun <R : Any?> foldRight(initial: R, operation: (T, acc) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in reverse order.
foldRightIndexed
inline fun <R : Any?> foldRightIndexed(initial: R, operation: (index: Int, T, acc) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in reverse order.
forEach
inline fun forEach(block: (T) -> Unit): Unit
Calls block for each element in the MutableVector, in order.
forEachIndexed
inline fun forEachIndexed(block: (Int, T) -> Unit): Unit
Calls block for each element in the MutableVector along with its index, in order.
forEachReversed
inline fun forEachReversed(block: (T) -> Unit): Unit
Calls block for each element in the MutableVector in reverse order.
forEachReversedIndexed
inline fun forEachReversedIndexed(block: (Int, T) -> Unit): Unit
Calls block for each element in the MutableVector along with its index, in reverse order.
indexOf
fun indexOf(element: T): Int
Returns the index of element in the MutableVector or -1 if element is not there.
indexOfFirst
inline fun indexOfFirst(predicate: (T) -> Boolean): Int
Returns the index if the first element in the MutableVector for which predicate returns true.
indexOfLast
inline fun indexOfLast(predicate: (T) -> Boolean): Int
Returns the index if the last element in the MutableVector for which predicate returns true.
isEmpty
inline fun isEmpty(): Boolean
Returns true if the MutableVector has no elements in it or false otherwise.
isNotEmpty
inline fun isNotEmpty(): Boolean
Returns true if there are elements in the MutableVector or false if it is empty.
last
fun last(): T
Returns the last element in the MutableVector or throws a NoSuchElementException if it isEmpty.
last
inline fun last(predicate: (T) -> Boolean): T
Returns the last element in the MutableVector for which predicate returns true or throws NoSuchElementException if nothing matches.
lastIndexOf
fun lastIndexOf(element: T): Int
Returns the index of the last element in the MutableVector that is the same as element or -1 if no elements match.
lastOrNull
inline fun lastOrNull(): T?
Returns the last element in the MutableVector or null if it isEmpty.
lastOrNull
inline fun lastOrNull(predicate: (T) -> Boolean): T?
Returns the last element in the MutableVector for which predicate returns true or returns null if nothing matches.
map
inline fun <R : Any?> map(transform: (T) -> R): Array<R>
Returns an Array of results of transforming each element in the MutableVector. The Array will be the same size as this.
mapIndexed
inline fun <R : Any?> mapIndexed(transform: (index: Int, T) -> R): Array<R>
Returns an Array of results of transforming each element in the MutableVector. The Array will be the same size as this.
mapIndexedNotNull
inline fun <R : Any?> mapIndexedNotNull(transform: (index: Int, T) -> R?): MutableVector<R>
Returns an MutableVector of results of transforming each element in the MutableVector, excluding those transformed values that are null.
mapNotNull
inline fun <R : Any?> mapNotNull(transform: (T) -> R?): MutableVector<R>
Returns an MutableVector of results of transforming each element in the MutableVector, excluding those transformed values that are null.
remove
fun remove(element: T): Boolean
Removes element from the MutableVector. If element was in the MutableVector and was removed, true will be returned, or false will be returned if the element was not found.
removeAll
fun removeAll(elements: Collection<T>): Boolean
Removes all elements from the MutableVector and returns true if anything was removed.
removeAll
fun removeAll(elements: List<T>): Boolean
Removes all elements from the MutableVector and returns true if anything was removed.
removeAll
fun removeAll(elements: MutableVector<T>): Boolean
Removes all elements from the MutableVector and returns true if anything was removed.
removeRange
fun removeRange(start: Int, end: Int): Unit
Removes items from index start (inclusive) to end (exclusive).
retainAll
fun retainAll(elements: Collection<T>): Boolean
Keeps only elements in the MutableVector and removes all other values.
reversedAny
inline fun reversedAny(predicate: (T) -> Boolean): Boolean
Returns true if any of the elements give a true return value for predicate while iterating in the reverse order.
sortWith
fun sortWith(comparator: Comparator<T>): Unit
Sorts the MutableVector using comparator to order the items.
sumBy
inline fun sumBy(selector: (T) -> Int): Int
Returns the sum of all values produced by selector for each element in the MutableVector.