Collection

interface Collection<out E> : Iterable<E> (source)

A generic collection of elements. Methods in this interface support only read-only access to the collection; read/write access is supported through the MutableCollection interface.

Since Kotlin

1.0
interface Collection<out E> : Iterable<E> (source)

A generic collection of elements. Methods in this interface support only read-only access to the collection; read/write access is supported through the MutableCollection interface.

Since Kotlin

1.1

Parameters

E

the type of elements contained in the collection. The collection is covariant in its element type.

E

the type of elements contained in the collection. The collection is covariant in its element type.

Functions

Link copied to clipboard
abstract operator fun contains(element: @UnsafeVariance E): Boolean

Checks if the specified element is contained in this collection.

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

Checks if the specified element is contained in this collection.

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

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

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

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

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

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

Since Kotlin 1.0
abstract 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

Properties

Link copied to clipboard
abstract val size: Int

Returns the size of the collection.

Since Kotlin 1.0
abstract val size: Int

Returns the size of the collection.

Since Kotlin 1.1

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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
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