MutableVector

class MutableVector<T> : RandomAccess

A MutableList-like structure with a simplified interface that offers faster access than ArrayList.

Functions

add
Link copied to clipboard
common
fun add(element: T): Boolean
Adds element to the MutableVector and returns true.
fun add(index: Int, element: T)
Adds element to the MutableVector at the given index, shifting over any elements that are in the way.
addAll
Link copied to clipboard
common
inline fun addAll(elements: MutableVector<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
fun addAll(elements: Array<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
fun addAll(elements: Collection<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
inline fun addAll(elements: List<T>): Boolean
Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.
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.
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.
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.
any
Link copied to clipboard
common
inline fun any(predicate: (T) -> Boolean): Boolean
Returns true if any of the elements give a true return value for predicate.
asMutableList
Link copied to clipboard
common
fun asMutableList(): MutableList<T>
Returns MutableList interface access to the MutableVector.
clear
Link copied to clipboard
common
fun clear()
Removes all elements in the MutableVector.
contains
Link copied to clipboard
common
operator fun contains(element: T): Boolean
Returns true if the MutableVector contains element or false otherwise.
containsAll
Link copied to clipboard
common
fun containsAll(elements: MutableVector<T>): Boolean
Returns true if the MutableVector contains all elements in elements or false if one or more are missing.
fun containsAll(elements: Collection<T>): Boolean
Returns true if the MutableVector contains all elements in elements or false if one or more are missing.
fun containsAll(elements: List<T>): Boolean
Returns true if the MutableVector contains all elements in elements or false if one or more are missing.
contentEquals
Link copied to clipboard
common
fun contentEquals(other: MutableVector<T>): Boolean
Returns true if the contents of the MutableVector are the same or false if there is any difference.
ensureCapacity
Link copied to clipboard
common
fun ensureCapacity(capacity: Int)
Ensures that there is enough space to store capacity elements in the MutableVector.
equals
Link copied to clipboard
common
open operator fun equals(other: Any?): Boolean
first
Link copied to clipboard
common
fun first(): T
Returns the first element in the MutableVector or throws a NoSuchElementException if it isEmpty.
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
Link copied to clipboard
common
inline fun firstOrNull(): T?
Returns the first element in the MutableVector or null if it isEmpty.
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
Link copied to clipboard
common
inline fun <R> fold(initial: R, operation: (R, T) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in order.
foldIndexed
Link copied to clipboard
common
inline fun <R> foldIndexed(initial: R, operation: (index: Int, R, T) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in order.
foldRight
Link copied to clipboard
common
inline fun <R> foldRight(initial: R, operation: (T, R) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in reverse order.
foldRightIndexed
Link copied to clipboard
common
inline fun <R> foldRightIndexed(initial: R, operation: (index: Int, T, R) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the MutableVector in reverse order.
forEach
Link copied to clipboard
common
inline fun forEach(block: (T) -> Unit)
Calls block for each element in the MutableVector, in order.
forEachIndexed
Link copied to clipboard
common
inline fun forEachIndexed(block: (Int, T) -> Unit)
Calls block for each element in the MutableVector along with its index, in order.
forEachReversed
Link copied to clipboard
common
inline fun forEachReversed(block: (T) -> Unit)
Calls block for each element in the MutableVector in reverse order.
forEachReversedIndexed
Link copied to clipboard
common
inline fun forEachReversedIndexed(block: (Int, T) -> Unit)
Calls block for each element in the MutableVector along with its index, in reverse order.
get
Link copied to clipboard
common
inline operator fun get(index: Int): T
Returns the element at the given index.
hashCode
Link copied to clipboard
common
open fun hashCode(): Int
indexOf
Link copied to clipboard
common
fun indexOf(element: T): Int
Returns the index of element in the MutableVector or -1 if element is not there.
indexOfFirst
Link copied to clipboard
common
inline fun indexOfFirst(predicate: (T) -> Boolean): Int
Returns the index if the first element in the MutableVector for which predicate returns true.
indexOfLast
Link copied to clipboard
common
inline fun indexOfLast(predicate: (T) -> Boolean): Int
Returns the index if the last element in the MutableVector for which predicate returns true.
isEmpty
Link copied to clipboard
common
fun isEmpty(): Boolean
Returns true if the MutableVector has no elements in it or false otherwise.
isNotEmpty
Link copied to clipboard
common
fun isNotEmpty(): Boolean
Returns true if there are elements in the MutableVector or false if it is empty.
last
Link copied to clipboard
common
fun last(): T
Returns the last element in the MutableVector or throws a NoSuchElementException if it isEmpty.
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
Link copied to clipboard
common
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
Link copied to clipboard
common
inline fun lastOrNull(): T?
Returns the last element in the MutableVector or null if it isEmpty.
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
Link copied to clipboard
common
inline fun <R> map(transform: (T) -> R): Array<R>
Returns an Array of results of transforming each element in the MutableVector.
mapIndexed
Link copied to clipboard
common
inline fun <R> mapIndexed(transform: (index: Int, T) -> R): Array<R>
Returns an Array of results of transforming each element in the MutableVector.
mapIndexedNotNull
Link copied to clipboard
common
inline fun <R> 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
Link copied to clipboard
common
inline fun <R> 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.
minusAssign
Link copied to clipboard
common
inline operator fun minusAssign(element: T)
remove from the MutableVector
plusAssign
Link copied to clipboard
common
inline operator fun plusAssign(element: T)
add to the MutableVector.
remove
Link copied to clipboard
common
fun remove(element: T): Boolean
Removes element from the MutableVector.
removeAll
Link copied to clipboard
common
fun removeAll(elements: MutableVector<T>): Boolean
Removes all elements from the MutableVector and returns true if anything was removed.
fun removeAll(elements: Collection<T>): Boolean
Removes all elements from the MutableVector and returns true if anything was removed.
fun removeAll(elements: List<T>): Boolean
Removes all elements from the MutableVector and returns true if anything was removed.
removeAt
Link copied to clipboard
common
fun removeAt(index: Int): T
Removes the element at the given index and returns it.
removeRange
Link copied to clipboard
common
fun removeRange(start: Int, end: Int)
Removes items from index start (inclusive) to end (exclusive).
retainAll
Link copied to clipboard
common
fun retainAll(elements: Collection<T>): Boolean
Keeps only elements in the MutableVector and removes all other values.
reversedAny
Link copied to clipboard
common
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.
set
Link copied to clipboard
common
operator fun set(index: Int, element: T): T
Sets the value at index to element.
sortWith
Link copied to clipboard
common
fun sortWith(comparator: Comparator<T>)
Sorts the MutableVector using comparator to order the items.
sumBy
Link copied to clipboard
common
inline fun sumBy(selector: (T) -> Int): Int
Returns the sum of all values produced by selector for each element in the MutableVector.
toString
Link copied to clipboard
common
open fun toString(): String

Properties

indices
Link copied to clipboard
common
val indices: IntRange
Returns an IntRange of the valid indices for this MutableVector.
lastIndex
Link copied to clipboard
common
val lastIndex: Int
Returns the last valid index in the MutableVector.
size
Link copied to clipboard
common
var size: Int
The number of elements in the MutableVector.