MutableList

A generic ordered collection of elements that supports adding and removing elements.

Since Kotlin

1.0

A generic ordered collection of elements that supports adding and removing elements.

Since Kotlin

1.1

Parameters

E

the type of elements contained in the list. The mutable list is invariant in its element type.

E

the type of elements contained in the list. The mutable list is invariant in its element type.

Functions

Link copied to clipboard
abstract override fun add(element: E): Boolean

Adds the specified element to the end of this list.

Since Kotlin 1.0
abstract fun add(index: Int, element: E)

Inserts an element into the list at the specified index.

Since Kotlin 1.0
abstract override fun add(element: E): Boolean

Adds the specified element to the end of this list.

Since Kotlin 1.1
abstract fun add(index: Int, element: E)

Inserts an element into the list at the specified index.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun addAll(elements: Collection<E>): Boolean

Adds all of the elements of the specified collection to the end of this list.

Since Kotlin 1.0
abstract fun addAll(index: Int, elements: Collection<E>): Boolean

Inserts all of the elements of the specified collection elements into this list at the specified index.

Since Kotlin 1.0
abstract override fun addAll(elements: Collection<E>): Boolean

Adds all of the elements of the specified collection to the end of this list.

Since Kotlin 1.1
abstract fun addAll(index: Int, elements: Collection<E>): Boolean

Inserts all of the elements of the specified collection elements into this list at the specified index.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun clear()

Removes all elements from this collection.

Since Kotlin 1.0
abstract override fun clear()

Removes all elements from this collection.

Since Kotlin 1.1
Link copied to clipboard
abstract operator override fun contains(element: E): Boolean

Checks if the specified element is contained in this collection.

Since Kotlin 1.0
abstract operator override fun contains(element: E): Boolean

Checks if the specified element is contained in this collection.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun containsAll(elements: Collection<E>): Boolean

Checks if all elements in the specified collection are contained in this collection.

Since Kotlin 1.0
abstract override fun containsAll(elements: Collection<E>): Boolean

Checks if all elements in the specified collection are contained in this collection.

Since Kotlin 1.1
Link copied to clipboard
abstract operator fun get(index: Int): E

Returns the element at the specified index in the list.

Since Kotlin 1.0
abstract operator fun get(index: Int): E

Returns the element at the specified index in the list.

Since Kotlin 1.1
Link copied to clipboard
abstract fun indexOf(element: E): Int

Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

Since Kotlin 1.0
abstract fun indexOf(element: E): Int

Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun isEmpty(): Boolean

Returns true if the collection is empty (contains no elements), false otherwise.

Since Kotlin 1.0
abstract override fun isEmpty(): Boolean

Returns true if the collection is empty (contains no elements), false otherwise.

Since Kotlin 1.1
Link copied to clipboard
abstract operator override fun iterator(): Iterator<E>

Returns an iterator over the elements of this object.

Since Kotlin 1.0
abstract operator override fun iterator(): Iterator<E>

Returns an iterator over the elements of this object.

Since Kotlin 1.1
Link copied to clipboard
abstract fun lastIndexOf(element: E): Int

Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

Since Kotlin 1.0
abstract fun lastIndexOf(element: E): Int

Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun listIterator(): MutableListIterator<E>

Returns a list iterator over the elements in this list (in proper sequence).

Since Kotlin 1.0
abstract override fun listIterator(index: Int): MutableListIterator<E>

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified index.

Since Kotlin 1.0
abstract override fun listIterator(): MutableListIterator<E>

Returns a list iterator over the elements in this list (in proper sequence).

Since Kotlin 1.1
abstract override fun listIterator(index: Int): MutableListIterator<E>

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified index.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun remove(element: E): Boolean

Removes a single instance of the specified element from this collection, if it is present.

Since Kotlin 1.0
abstract override fun remove(element: E): Boolean

Removes a single instance of the specified element from this collection, if it is present.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun removeAll(elements: Collection<E>): Boolean

Removes all of this collection's elements that are also contained in the specified collection.

Since Kotlin 1.0
abstract override fun removeAll(elements: Collection<E>): Boolean

Removes all of this collection's elements that are also contained in the specified collection.

Since Kotlin 1.1
Link copied to clipboard
abstract fun removeAt(index: Int): E

Removes an element at the specified index from the list.

Since Kotlin 1.0
abstract fun removeAt(index: Int): E

Removes an element at the specified index from the list.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun retainAll(elements: Collection<E>): Boolean

Retains only the elements in this collection that are contained in the specified collection.

Since Kotlin 1.0
abstract override fun retainAll(elements: Collection<E>): Boolean

Retains only the elements in this collection that are contained in the specified collection.

Since Kotlin 1.1
Link copied to clipboard
abstract operator fun set(index: Int, element: E): E

Replaces the element at the specified position in this list with the specified element.

Since Kotlin 1.0
abstract operator fun set(index: Int, element: E): E

Replaces the element at the specified position in this list with the specified element.

Since Kotlin 1.1
Link copied to clipboard
abstract override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>

Returns a view of the portion of this list between the specified fromIndex (inclusive) and toIndex (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.

Since Kotlin 1.0
abstract override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>

Returns a view of the portion of this list between the specified fromIndex (inclusive) and toIndex (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.

Since Kotlin 1.1

Properties

Link copied to clipboard
abstract override val size: Int

Returns the size of the collection.

Since Kotlin 1.0
abstract override val size: Int

Returns the size of the collection.

Since Kotlin 1.1

Extensions

Link copied to clipboard
fun <R> Iterable<*>.filterIsInstance(klass: Class<R>): List<R>
fun <R> Iterable<*>.filterIsInstance(klass: Class<R>): List<R>

Returns a list containing all elements that are instances of specified class.

Since Kotlin 1.0
Link copied to clipboard
fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C
fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C

Appends all elements that are instances of specified class to the given destination.

Since Kotlin 1.0
Link copied to clipboard
Since Kotlin 1.1
fun <T : Comparable<T>> Iterable<T>.max(): T?
fun <T : Comparable<T>> Iterable<T>.max(): T?
Since Kotlin 1.0
Link copied to clipboard
inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T?
inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T?
Since Kotlin 1.0
Link copied to clipboard
fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T?
fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T?
Since Kotlin 1.0
Link copied to clipboard
Since Kotlin 1.1
fun <T : Comparable<T>> Iterable<T>.min(): T?
fun <T : Comparable<T>> Iterable<T>.min(): T?
Since Kotlin 1.0
Link copied to clipboard
inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T?
inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T?
Since Kotlin 1.0
Link copied to clipboard
fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T?
fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T?
Since Kotlin 1.0
Link copied to clipboard
inline fun <T> MutableList<T>.sort(comparator: Comparator<in T>)
inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int)
inline fun <T> MutableList<T>.sort(comparator: Comparator<in T>)
inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int)
Since Kotlin 1.0
Link copied to clipboard
fun <T> Iterable<T>.toSortedSet(comparator: Comparator<in T>): SortedSet<T>
fun <T> Iterable<T>.toSortedSet(comparator: Comparator<in T>): SortedSet<T>

Returns a new SortedSet of all elements.

Since Kotlin 1.0