<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
public class MutableVector<T>
@PublishedApi
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`.


## Functions



<h2 id="add-element">add</h2>

```kotlin
public fun add(element: T): Boolean
```


Adds `element` to the `MutableVector` and returns `true`.




<hr class="docs-overload-divider">


<h2 id="add-index-element">add</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-index-elements">addAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-index-elements-2">addAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-elements">addAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-elements-2">addAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-elements-3">addAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-index-elements-3">addAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="addall-elements-4">addAll</h2>

```kotlin
public fun addAll(elements: Collection<T>): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="any-predicate">any</h2>

```kotlin
public inline fun any(predicate: (T) -> Boolean): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="reversedany-predicate">reversedAny</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="asmutablelist">asMutableList</h2>

```kotlin
public fun asMutableList(): MutableList<T>
```


Returns `MutableList` interface access to the `MutableVector`.




<hr class="docs-overload-divider">


<h2 id="clear">clear</h2>

```kotlin
public fun clear()
```


Removes all elements in the `MutableVector`.




<hr class="docs-overload-divider">


<h2 id="contains-element">contains</h2>

```kotlin
public operator fun contains(element: T): Boolean
```


Returns `true` if the `MutableVector` contains `element` or `false` otherwise.




<hr class="docs-overload-divider">


<h2 id="containsall-elements">containsAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="containsall-elements-2">containsAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="containsall-elements-3">containsAll</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="contentequals-other">contentEquals</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="ensurecapacity-capacity">ensureCapacity</h2>

```kotlin
public inline fun ensureCapacity(capacity: Int)
```


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




<hr class="docs-overload-divider">


<h2 id="first">first</h2>

```kotlin
public fun first(): T
```


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




<hr class="docs-overload-divider">


<h2 id="first-predicate">first</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="firstornull">firstOrNull</h2>

```kotlin
public inline fun firstOrNull(): T?
```


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




<hr class="docs-overload-divider">


<h2 id="firstornull-predicate">firstOrNull</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="fold-initial-operation-acc">fold</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="foldindexed-initial-operation-index-acc">foldIndexed</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="foldright-initial-operation-acc">foldRight</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="foldrightindexed-initial-operation-index-acc">foldRightIndexed</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="foreach-block">forEach</h2>

```kotlin
public inline fun forEach(block: (T) -> Unit)
```


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




<hr class="docs-overload-divider">


<h2 id="foreachindexed-block">forEachIndexed</h2>

```kotlin
public inline fun forEachIndexed(block: (Int, T) -> Unit)
```


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




<hr class="docs-overload-divider">


<h2 id="foreachreversed-block">forEachReversed</h2>

```kotlin
public inline fun forEachReversed(block: (T) -> Unit)
```


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




<hr class="docs-overload-divider">


<h2 id="foreachreversedindexed-block">forEachReversedIndexed</h2>

```kotlin
public inline fun forEachReversedIndexed(block: (Int, T) -> Unit)
```


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




<hr class="docs-overload-divider">


<h2 id="get-index">get</h2>

```kotlin
public inline operator fun get(index: Int): T
```


Returns the element at the given `index`.




<hr class="docs-overload-divider">


<h2 id="indexof-element">indexOf</h2>

```kotlin
public fun indexOf(element: T): Int
```


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




<hr class="docs-overload-divider">


<h2 id="indexoffirst-predicate">indexOfFirst</h2>

```kotlin
public inline fun indexOfFirst(predicate: (T) -> Boolean): Int
```


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




<hr class="docs-overload-divider">


<h2 id="indexoflast-predicate">indexOfLast</h2>

```kotlin
public inline fun indexOfLast(predicate: (T) -> Boolean): Int
```


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




<hr class="docs-overload-divider">


<h2 id="isempty">isEmpty</h2>

```kotlin
public inline fun isEmpty(): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="isnotempty">isNotEmpty</h2>

```kotlin
public inline fun isNotEmpty(): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="last">last</h2>

```kotlin
public fun last(): T
```


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




<hr class="docs-overload-divider">


<h2 id="last-predicate">last</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="lastindexof-element">lastIndexOf</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="lastornull">lastOrNull</h2>

```kotlin
public inline fun lastOrNull(): T?
```


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




<hr class="docs-overload-divider">


<h2 id="lastornull-predicate">lastOrNull</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="map-transform">map</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="mapindexed-transform-index">mapIndexed</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="mapindexednotnull-transform">mapIndexedNotNull</h2>

```kotlin
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`.




<hr class="docs-overload-divider">


<h2 id="mapnotnull-transform">mapNotNull</h2>

```kotlin
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`.




<hr class="docs-overload-divider">


<h2 id="plusassign-element">plusAssign</h2>

```kotlin
public inline operator fun plusAssign(element: T)
```


`add` `element` to the `MutableVector`.




<hr class="docs-overload-divider">


<h2 id="minusassign-element">minusAssign</h2>

```kotlin
public inline operator fun minusAssign(element: T)
```


`remove` `element` from the `MutableVector`




<hr class="docs-overload-divider">


<h2 id="remove-element">remove</h2>

```kotlin
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.




<hr class="docs-overload-divider">


<h2 id="removeall-elements">removeAll</h2>

```kotlin
public fun removeAll(elements: List<T>): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="removeall-elements-2">removeAll</h2>

```kotlin
public fun removeAll(elements: MutableVector<T>): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="removeall-elements-3">removeAll</h2>

```kotlin
public fun removeAll(elements: Collection<T>): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="removeat-index">removeAt</h2>

```kotlin
public fun removeAt(index: Int): T
```


Removes the element at the given `index` and returns it.




<hr class="docs-overload-divider">


<h2 id="removerange-start-end">removeRange</h2>

```kotlin
public fun removeRange(start: Int, end: Int)
```


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




<hr class="docs-overload-divider">


<h2 id="removeif-predicate">removeIf</h2>

```kotlin
public inline fun removeIf(predicate: (T) -> Boolean)
```


Removes items that satisfy `predicate`




<hr class="docs-overload-divider">


<h2 id="retainall-elements">retainAll</h2>

```kotlin
public fun retainAll(elements: Collection<T>): Boolean
```


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




<hr class="docs-overload-divider">


<h2 id="set-index-element">set</h2>

```kotlin
public operator fun set(index: Int, element: T): T
```


Sets the value at `index` to `element`.




<hr class="docs-overload-divider">


<h2 id="sortwith-comparator">sortWith</h2>

```kotlin
public fun sortWith(comparator: Comparator<T>)
```


Sorts the `MutableVector` using `comparator` to order the items.




<hr class="docs-overload-divider">


<h2 id="sumby-selector">sumBy</h2>

```kotlin
public inline fun sumBy(selector: (T) -> Int): Int
```


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