🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

MutableVector

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

Source set: Common
public class MutableVector<T> internal constructor(@PublishedApi @JvmField internal var content: Array<T?>, size: Int) :
    RandomAccess

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

Properties

size

Source set: Common
public var size: Int = size

The number of elements in the MutableVector.

lastIndex

Source set: Common
public inline val lastIndex: Int

Returns the last valid index in the MutableVector.

indices

Source set: Common
public inline val indices: IntRange

Returns an IntRange of the valid indices for this MutableVector.

Functions

add

Source set: Common
public fun add(element: T): Boolean

Adds element to the MutableVector and returns true.

add

Source set: Common
public 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

Source set: Common
public 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

Source set: Common
public 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.

addAll

Source set: Common
public 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

Source set: Common
public 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

Source set: Common
public fun addAll(@Suppress("ArrayReturn") elements: Array<T>): Boolean

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

addAll

Source set: Common
public 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

Source set: Common
public fun addAll(elements: Collection<T>): Boolean

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

any

Source set: Common
public inline fun any(predicate: (T) -> Boolean): Boolean

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

reversedAny

Source set: Common
public 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.

asMutableList

Source set: Common
public fun asMutableList(): MutableList<T>

Returns MutableList interface access to the MutableVector.

clear

Source set: Common
public fun clear()

Removes all elements in the MutableVector.

contains

Source set: Common
public operator fun contains(element: T): Boolean

Returns true if the MutableVector contains element or false otherwise.

containsAll

Source set: Common
public 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

Source set: Common
public 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

Source set: Common
public 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

Source set: Common
public 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

Source set: Common
public inline fun ensureCapacity(capacity: Int)

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

first

Source set: Common
public fun first(): T

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

first

Source set: Common
public 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

Source set: Common
public inline fun firstOrNull(): T?

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

firstOrNull

Source set: Common
public 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

Source set: Common
public inline fun <R> fold(initial: R, operation: (acc: R, T) -> R): R

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

foldIndexed

Source set: Common
public inline fun <R> foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R

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

foldRight

Source set: Common
public inline fun <R> foldRight(initial: R, operation: (T, acc: R) -> R): R

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

foldRightIndexed

Source set: Common
public inline fun <R> foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R): R

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

forEach

Source set: Common
public inline fun forEach(block: (T) -> Unit)

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

forEachIndexed

Source set: Common
public inline fun forEachIndexed(block: (Int, T) -> Unit)

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

forEachReversed

Source set: Common
public inline fun forEachReversed(block: (T) -> Unit)

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

forEachReversedIndexed

Source set: Common
public inline fun forEachReversedIndexed(block: (Int, T) -> Unit)

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

get

Source set: Common
public inline operator fun get(index: Int): T

Returns the element at the given index.

indexOf

Source set: Common
public fun indexOf(element: T): Int

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

indexOfFirst

Source set: Common
public inline fun indexOfFirst(predicate: (T) -> Boolean): Int

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

indexOfLast

Source set: Common
public inline fun indexOfLast(predicate: (T) -> Boolean): Int

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

isEmpty

Source set: Common
public inline fun isEmpty(): Boolean

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

isNotEmpty

Source set: Common
public inline fun isNotEmpty(): Boolean

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

last

Source set: Common
public fun last(): T

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

last

Source set: Common
public 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

Source set: Common
public 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

Source set: Common
public inline fun lastOrNull(): T?

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

lastOrNull

Source set: Common
public 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

Source set: Common
public inline fun <reified R> 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

Source set: Common
public inline fun <reified R> 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

Source set: Common
public inline fun <reified 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

Source set: Common
public inline fun <reified 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.

plusAssign

Source set: Common
public inline operator fun plusAssign(element: T)

add element to the MutableVector.

minusAssign

Source set: Common
public inline operator fun minusAssign(element: T)

remove element from the MutableVector

remove

Source set: Common
public 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

Source set: Common
public fun removeAll(elements: List<T>): Boolean

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

removeAll

Source set: Common
public fun removeAll(elements: MutableVector<T>): Boolean

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

removeAll

Source set: Common
public fun removeAll(elements: Collection<T>): Boolean

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

removeAt

Source set: Common
public fun removeAt(index: Int): T

Removes the element at the given index and returns it.

removeRange

Source set: Common
public fun removeRange(start: Int, end: Int)

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

removeIf

Source set: Common
public inline fun removeIf(predicate: (T) -> Boolean)

Removes items that satisfy predicate

retainAll

Source set: Common
public fun retainAll(elements: Collection<T>): Boolean

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

set

Source set: Common
public operator fun set(index: Int, element: T): T

Sets the value at index to element.

sortWith

Source set: Common
public fun sortWith(comparator: Comparator<T>)

Sorts the MutableVector using comparator to order the items.

sumBy

Source set: Common
public inline fun sumBy(selector: (T) -> Int): Int

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