AbstractMutableCollection

abstract class AbstractMutableCollection<E> : 
    MutableCollection<E>,
    AbstractCollection<E>
(source)

Platform and version requirements: Kotlin 1.1

Provides a skeletal implementation of the MutableCollection interface.

Parameters

E - the type of elements contained in the collection. The collection is invariant on its element type.

Constructors

<init>

AbstractMutableCollection()

Provides a skeletal implementation of the MutableCollection interface.

Inherited Properties

size

abstract val size: Int

Returns the size of the collection.

Functions

add

abstract fun add(element: E): Boolean

Adds the specified element to the collection.

addAll

open fun addAll(elements: Collection<E>): Boolean

Adds all of the elements in the specified collection to this collection.

clear

open fun clear()

Removes all elements from this collection.

remove

open fun remove(element: E): Boolean

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

removeAll

open fun removeAll(elements: Collection<E>): Boolean

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

retainAll

open fun retainAll(elements: Collection<E>): Boolean

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

toJSON

open fun toJSON(): Any

Inherited Functions

addAll

abstract fun addAll(elements: Collection<E>): Boolean

Adds all of the elements in the specified collection to this collection.

clear

abstract fun clear()

Removes all elements from this collection.

contains

open fun contains(element: E): Boolean

Checks if the specified element is contained in this collection.

containsAll

open fun containsAll(elements: Collection<E>): Boolean

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

isEmpty

open fun isEmpty(): Boolean

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

iterator

abstract fun iterator(): MutableIterator<E>

Returns an iterator over the elements of this object.

iterator

abstract fun iterator(): Iterator<E>

Returns an iterator over the elements of this object.

remove

abstract fun remove(element: E): Boolean

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

removeAll

abstract fun removeAll(elements: Collection<E>): Boolean

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

retainAll

abstract fun retainAll(elements: Collection<E>): Boolean

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

toArray

open fun <T> toArray(array: Array<T>): Array<T>

Fills the provided array or creates new array of the same type and fills it with the elements of this collection.

open fun toArray(): Array<Any?>

Returns new array of type Array<Any?> with the elements of this collection.

toString

open fun toString(): String

Returns a string representation of the object.

Extension Functions

filterIsInstance

fun <R> Iterable<*>.filterIsInstance(
    klass: Class<R>
): List<R>

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

filterIsInstanceTo

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.

shuffled

actual fun <T> Iterable<T>.shuffled(): List<T>

Returns a new list with the elements of this list randomly shuffled.

fun <T> Iterable<T>.shuffled(random: Random): List<T>

Returns a new list with the elements of this list randomly shuffled using the specified random instance as the source of randomness.

toSortedSet

fun <T : Comparable<T>> Iterable<T>.toSortedSet(): SortedSet<T>
fun <T> Iterable<T>.toSortedSet(
    comparator: Comparator<in T>
): SortedSet<T>

Returns a SortedSet of all elements.

toTypedArray

actual fun <T> Collection<T>.toTypedArray(): Array<T>

Returns a typed array containing all of the elements of this collection.