MutableVector


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

Summary

Public functions

Boolean
add(element: T)

Adds element to the MutableVector and returns true.

Cmn
Unit
add(index: Int, element: T)

Adds element to the MutableVector at the given index, shifting over any elements that are in the way.

Cmn
Boolean
addAll(elements: Array<T>)

Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.

Cmn
Boolean
addAll(elements: Collection<T>)

Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.

Cmn
inline Boolean
addAll(elements: List<T>)

Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.

Cmn
inline Boolean
addAll(elements: MutableVector<T>)

Adds all elements to the end of the MutableVector and returns true if the MutableVector was changed.

Cmn
Boolean
addAll(index: Int, elements: Collection<T>)

Adds all elements to the MutableVector at the given index, shifting over any elements that are in the way.

Cmn
Boolean
addAll(index: Int, elements: List<T>)

Adds all elements to the MutableVector at the given index, shifting over any elements that are in the way.

Cmn
Boolean
addAll(index: Int, elements: MutableVector<T>)

Adds all elements to the MutableVector at the given index, shifting over any elements that are in the way.

Cmn
inline Boolean
any(predicate: (T) -> Boolean)

Returns true if any of the elements give a true return value for predicate.

Cmn
MutableList<T>

Returns MutableList interface access to the MutableVector.

Cmn
Unit

Removes all elements in the MutableVector.

Cmn
operator Boolean
contains(element: T)

Returns true if the MutableVector contains element or false otherwise.

Cmn
Boolean
containsAll(elements: Collection<T>)

Returns true if the MutableVector contains all elements in elements or false if one or more are missing.

Cmn
Boolean
containsAll(elements: List<T>)

Returns true if the MutableVector contains all elements in elements or false if one or more are missing.

Cmn
Boolean
containsAll(elements: MutableVector<T>)

Returns true if the MutableVector contains all elements in elements or false if one or more are missing.

Cmn
Boolean

Returns true if the contents of the MutableVector are the same or false if there is any difference.

Cmn
Unit
ensureCapacity(capacity: Int)

Ensures that there is enough space to store capacity elements in the MutableVector.

Cmn
T

Returns the first element in the MutableVector or throws a NoSuchElementException if it isEmpty.

Cmn
inline T
first(predicate: (T) -> Boolean)

Returns the first element in the MutableVector for which predicate returns true or throws NoSuchElementException if nothing matches.

Cmn
inline T?

Returns the first element in the MutableVector or null if it isEmpty.

Cmn
inline T?
firstOrNull(predicate: (T) -> Boolean)

Returns the first element in the MutableVector for which predicate returns true or returns null if nothing matches.

Cmn
inline R
<R : Any?> fold(initial: R, operation: (acc, T) -> R)

Accumulates values, starting with initial, and applying operation to each element in the MutableVector in order.

Cmn
inline R
<R : Any?> foldIndexed(initial: R, operation: (index: Int, acc, T) -> R)

Accumulates values, starting with initial, and applying operation to each element in the MutableVector in order.

Cmn
inline R
<R : Any?> foldRight(initial: R, operation: (T, acc) -> R)

Accumulates values, starting with initial, and applying operation to each element in the MutableVector in reverse order.

Cmn
inline R
<R : Any?> foldRightIndexed(initial: R, operation: (index: Int, T, acc) -> R)

Accumulates values, starting with initial, and applying operation to each element in the MutableVector in reverse order.

Cmn
inline Unit
forEach(block: (T) -> Unit)

Calls block for each element in the MutableVector, in order.

Cmn
inline Unit
forEachIndexed(block: (Int, T) -> Unit)

Calls block for each element in the MutableVector along with its index, in order.

Cmn
inline Unit
forEachReversed(block: (T) -> Unit)

Calls block for each element in the MutableVector in reverse order.

Cmn
inline Unit

Calls block for each element in the MutableVector along with its index, in reverse order.

Cmn
inline operator T
get(index: Int)

Returns the element at the given index.

Cmn
Int
indexOf(element: T)

Returns the index of element in the MutableVector or -1 if element is not there.

Cmn
inline Int
indexOfFirst(predicate: (T) -> Boolean)

Returns the index if the first element in the MutableVector for which predicate returns true.

Cmn
inline Int
indexOfLast(predicate: (T) -> Boolean)

Returns the index if the last element in the MutableVector for which predicate returns true.

Cmn
Boolean

Returns true if the MutableVector has no elements in it or false otherwise.

Cmn
Boolean

Returns true if there are elements in the MutableVector or false if it is empty.

Cmn
T

Returns the last element in the MutableVector or throws a NoSuchElementException if it isEmpty.

Cmn
inline T
last(predicate: (T) -> Boolean)

Returns the last element in the MutableVector for which predicate returns true or throws NoSuchElementException if nothing matches.

Cmn
Int
lastIndexOf(element: T)

Returns the index of the last element in the MutableVector that is the same as element or -1 if no elements match.

Cmn
inline T?

Returns the last element in the MutableVector or null if it isEmpty.

Cmn
inline T?
lastOrNull(predicate: (T) -> Boolean)

Returns the last element in the MutableVector for which predicate returns true or returns null if nothing matches.

Cmn
inline Array<R>
<R : Any?> map(transform: (T) -> R)

Returns an Array of results of transforming each element in the MutableVector.

Cmn
inline Array<R>
<R : Any?> mapIndexed(transform: (index: Int, T) -> R)

Returns an Array of results of transforming each element in the MutableVector.

Cmn
inline MutableVector<R>
<R : Any?> mapIndexedNotNull(transform: (index: Int, T) -> R?)

Returns an MutableVector of results of transforming each element in the MutableVector, excluding those transformed values that are null.

Cmn
inline MutableVector<R>
<R : Any?> mapNotNull(transform: (T) -> R?)

Returns an MutableVector of results of transforming each element in the MutableVector, excluding those transformed values that are null.

Cmn
inline operator Unit
minusAssign(element: T)

remove from the MutableVector

Cmn
inline operator Unit
plusAssign(element: T)

add to the MutableVector.

Cmn
Boolean
remove(element: T)

Removes element from the MutableVector.

Cmn
Boolean
removeAll(elements: Collection<T>)

Removes all elements from the MutableVector and returns true if anything was removed.

Cmn
Boolean
removeAll(elements: List<T>)

Removes all elements from the MutableVector and returns true if anything was removed.

Cmn
Boolean
removeAll(elements: MutableVector<T>)

Removes all elements from the MutableVector and returns true if anything was removed.

Cmn
T
removeAt(index: Int)

Removes the element at the given index and returns it.

Cmn
inline Unit
removeIf(predicate: (T) -> Boolean)

Removes items that satisfy predicate

Cmn
Unit
removeRange(start: Int, end: Int)

Removes items from index start (inclusive) to end (exclusive).

Cmn
Boolean
retainAll(elements: Collection<T>)

Keeps only elements in the MutableVector and removes all other values.

Cmn
inline Boolean
reversedAny(predicate: (T) -> Boolean)

Returns true if any of the elements give a true return value for predicate while iterating in the reverse order.

Cmn
operator T
set(index: Int, element: T)

Sets the value at index to element.

Cmn
Unit
sortWith(comparator: Comparator<T>)

Sorts the MutableVector using comparator to order the items.

Cmn
inline Int
sumBy(selector: (T) -> Int)

Returns the sum of all values produced by selector for each element in the MutableVector.

Cmn

Public properties

IntRange

Returns an IntRange of the valid indices for this MutableVector.

Cmn
Int

Returns the last valid index in the MutableVector.

Cmn
Int

The number of elements in the MutableVector.

Cmn

Public functions

add

fun add(element: T): Boolean

Adds element to the MutableVector and returns true.

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.

clear

fun clear(): Unit

Removes all elements in 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

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.

get

inline operator fun get(index: Int): T

Returns the element at the given index.

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

fun isEmpty(): Boolean

Returns true if the MutableVector has no elements in it or false otherwise.

isNotEmpty

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.

minusAssign

inline operator fun minusAssign(element: T): Unit

remove from the MutableVector

plusAssign

inline operator fun plusAssign(element: T): Unit

add to the MutableVector.

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.

removeAt

fun removeAt(index: Int): T

Removes the element at the given index and returns it.

removeIf

inline fun removeIf(predicate: (T) -> Boolean): Unit

Removes items that satisfy predicate

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.

set

operator fun set(index: Int, element: T): T

Sets the value at index to element.

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.

Public properties

indices

val indicesIntRange

Returns an IntRange of the valid indices for this MutableVector.

lastIndex

val lastIndexInt

Returns the last valid index in the MutableVector.

size

val sizeInt

The number of elements in the MutableVector.