Fix doc wording around covariance/invariance

This commit is contained in:
Ilya Gorbunov
2020-07-28 14:38:08 +03:00
parent 4f73e08704
commit 99eb7f391b
19 changed files with 85 additions and 98 deletions
+14 -25
View File
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package kotlin.collections package kotlin.collections
@@ -21,7 +10,7 @@ import kotlin.internal.PlatformDependent
/** /**
* Classes that inherit from this interface can be represented as a sequence of elements that can * Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over. * be iterated over.
* @param T the type of element being iterated over. The iterator is covariant on its element type. * @param T the type of element being iterated over. The iterator is covariant in its element type.
*/ */
public interface Iterable<out T> { public interface Iterable<out T> {
/** /**
@@ -33,7 +22,7 @@ public interface Iterable<out T> {
/** /**
* Classes that inherit from this interface can be represented as a sequence of elements that can * Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over and that supports removing elements during iteration. * be iterated over and that supports removing elements during iteration.
* @param T the type of element being iterated over. The mutable iterator is invariant on its element type. * @param T the type of element being iterated over. The mutable iterator is invariant in its element type.
*/ */
public interface MutableIterable<out T> : Iterable<T> { public interface MutableIterable<out T> : Iterable<T> {
/** /**
@@ -45,7 +34,7 @@ public interface MutableIterable<out T> : Iterable<T> {
/** /**
* A generic collection of elements. Methods in this interface support only read-only access to the collection; * 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. * read/write access is supported through the [MutableCollection] interface.
* @param E the type of elements contained in the collection. The collection is covariant on its element type. * @param E the type of elements contained in the collection. The collection is covariant in its element type.
*/ */
public interface Collection<out E> : Iterable<E> { public interface Collection<out E> : Iterable<E> {
// Query Operations // Query Operations
@@ -76,7 +65,7 @@ public interface Collection<out E> : Iterable<E> {
/** /**
* A generic collection of elements that supports adding and removing elements. * A generic collection of elements that supports adding and removing elements.
* *
* @param E the type of elements contained in the collection. The mutable collection is invariant on its element type. * @param E the type of elements contained in the collection. The mutable collection is invariant in its element type.
*/ */
public interface MutableCollection<E> : Collection<E>, MutableIterable<E> { public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
// Query Operations // Query Operations
@@ -130,7 +119,7 @@ public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
/** /**
* A generic ordered collection of elements. Methods in this interface support only read-only access to the list; * A generic ordered collection of elements. Methods in this interface support only read-only access to the list;
* read/write access is supported through the [MutableList] interface. * read/write access is supported through the [MutableList] interface.
* @param E the type of elements contained in the list. The list is covariant on its element type. * @param E the type of elements contained in the list. The list is covariant in its element type.
*/ */
public interface List<out E> : Collection<E> { public interface List<out E> : Collection<E> {
// Query Operations // Query Operations
@@ -185,7 +174,7 @@ public interface List<out E> : Collection<E> {
/** /**
* A generic ordered collection of elements that supports adding and removing elements. * A generic ordered collection of elements that supports adding and removing elements.
* @param E the type of elements contained in the list. The mutable list is invariant on its element type. * @param E the type of elements contained in the list. The mutable list is invariant in its element type.
*/ */
public interface MutableList<E> : List<E>, MutableCollection<E> { public interface MutableList<E> : List<E>, MutableCollection<E> {
// Modification Operations // Modification Operations
@@ -252,7 +241,7 @@ public interface MutableList<E> : List<E>, MutableCollection<E> {
* A generic unordered collection of elements that does not support duplicate elements. * A generic unordered collection of elements that does not support duplicate elements.
* Methods in this interface support only read-only access to the set; * Methods in this interface support only read-only access to the set;
* read/write access is supported through the [MutableSet] interface. * read/write access is supported through the [MutableSet] interface.
* @param E the type of elements contained in the set. The set is covariant on its element type. * @param E the type of elements contained in the set. The set is covariant in its element type.
*/ */
public interface Set<out E> : Collection<E> { public interface Set<out E> : Collection<E> {
// Query Operations // Query Operations
@@ -269,7 +258,7 @@ public interface Set<out E> : Collection<E> {
/** /**
* A generic unordered collection of elements that does not support duplicate elements, and supports * A generic unordered collection of elements that does not support duplicate elements, and supports
* adding and removing elements. * adding and removing elements.
* @param E the type of elements contained in the set. The mutable set is invariant on its element type. * @param E the type of elements contained in the set. The mutable set is invariant in its element type.
*/ */
public interface MutableSet<E> : Set<E>, MutableCollection<E> { public interface MutableSet<E> : Set<E>, MutableCollection<E> {
// Query Operations // Query Operations
@@ -299,9 +288,9 @@ public interface MutableSet<E> : Set<E>, MutableCollection<E> {
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key. * the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* Methods in this interface support only read-only access to the map; read-write access is supported through * Methods in this interface support only read-only access to the map; read-write access is supported through
* the [MutableMap] interface. * the [MutableMap] interface.
* @param K the type of map keys. The map is invariant on its key type, as it * @param K the type of map keys. The map is invariant in its key type, as it
* can accept key as a parameter (of [containsKey] for example) and return it in [keys] set. * can accept key as a parameter (of [containsKey] for example) and return it in [keys] set.
* @param V the type of map values. The map is covariant on its value type. * @param V the type of map values. The map is covariant in its value type.
*/ */
public interface Map<K, out V> { public interface Map<K, out V> {
// Query Operations // Query Operations
@@ -377,8 +366,8 @@ public interface Map<K, out V> {
/** /**
* A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving * A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key. * the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The mutable map is invariant on its value type. * @param V the type of map values. The mutable map is invariant in its value type.
*/ */
public interface MutableMap<K, V> : Map<K, V> { public interface MutableMap<K, V> : Map<K, V> {
// Modification Operations // Modification Operations
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -8,7 +8,7 @@ package kotlin.collections
/** /**
* Provides a skeletal implementation of the [MutableCollection] interface. * Provides a skeletal implementation of the [MutableCollection] interface.
* *
* @param E the type of elements contained in the collection. The collection is invariant on its element type. * @param E the type of elements contained in the collection. The collection is invariant in its element type.
*/ */
@SinceKotlin("1.3") @SinceKotlin("1.3")
public expect abstract class AbstractMutableCollection<E> : MutableCollection<E> { public expect abstract class AbstractMutableCollection<E> : MutableCollection<E> {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -8,7 +8,7 @@ package kotlin.collections
/** /**
* Provides a skeletal implementation of the [MutableList] interface. * Provides a skeletal implementation of the [MutableList] interface.
* *
* @param E the type of elements contained in the list. The list is invariant on its element type. * @param E the type of elements contained in the list. The list is invariant in its element type.
*/ */
public expect abstract class AbstractMutableList<E> : MutableList<E> { public expect abstract class AbstractMutableList<E> : MutableList<E> {
protected constructor() protected constructor()
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -10,8 +10,8 @@ package kotlin.collections
* *
* The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function. * The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function.
* *
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The map is invariant on its value type. * @param V the type of map values. The map is invariant in its value type.
*/ */
@SinceKotlin("1.3") @SinceKotlin("1.3")
public expect abstract class AbstractMutableMap<K, V> : MutableMap<K, V> { public expect abstract class AbstractMutableMap<K, V> : MutableMap<K, V> {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -8,7 +8,7 @@ package kotlin.collections
/** /**
* Provides a skeletal implementation of the [MutableSet] interface. * Provides a skeletal implementation of the [MutableSet] interface.
* *
* @param E the type of elements contained in the set. The set is invariant on its element type. * @param E the type of elements contained in the set. The set is invariant in its element type.
*/ */
@SinceKotlin("1.3") @SinceKotlin("1.3")
public expect abstract class AbstractMutableSet<E> : MutableSet<E> { public expect abstract class AbstractMutableSet<E> : MutableSet<E> {
+17 -12
View File
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress( @file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY", "NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT", "MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
@@ -26,7 +31,7 @@ package kotlin.collections
/** /**
* Classes that inherit from this interface can be represented as a sequence of elements that can * Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over. * be iterated over.
* @param T the type of element being iterated over. The iterator is covariant on its element type. * @param T the type of element being iterated over. The iterator is covariant in its element type.
*/ */
public interface Iterable<out T> { public interface Iterable<out T> {
/** /**
@@ -38,7 +43,7 @@ public interface Iterable<out T> {
/** /**
* Classes that inherit from this interface can be represented as a sequence of elements that can * Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over and that supports removing elements during iteration. * be iterated over and that supports removing elements during iteration.
* @param T the type of element being iterated over. The mutable iterator is invariant on its element type. * @param T the type of element being iterated over. The mutable iterator is invariant in its element type.
*/ */
public interface MutableIterable<out T> : Iterable<T> { public interface MutableIterable<out T> : Iterable<T> {
/** /**
@@ -50,7 +55,7 @@ public interface MutableIterable<out T> : Iterable<T> {
/** /**
* A generic collection of elements. Methods in this interface support only read-only access to the collection; * 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. * read/write access is supported through the [MutableCollection] interface.
* @param E the type of elements contained in the collection. The collection is covariant on its element type. * @param E the type of elements contained in the collection. The collection is covariant in its element type.
*/ */
public interface Collection<out E> : Iterable<E> { public interface Collection<out E> : Iterable<E> {
// Query Operations // Query Operations
@@ -81,7 +86,7 @@ public interface Collection<out E> : Iterable<E> {
/** /**
* A generic collection of elements that supports adding and removing elements. * A generic collection of elements that supports adding and removing elements.
* *
* @param E the type of elements contained in the collection. The mutable collection is invariant on its element type. * @param E the type of elements contained in the collection. The mutable collection is invariant in its element type.
*/ */
public interface MutableCollection<E> : Collection<E>, MutableIterable<E> { public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
// Query Operations // Query Operations
@@ -135,7 +140,7 @@ public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
/** /**
* A generic ordered collection of elements. Methods in this interface support only read-only access to the list; * A generic ordered collection of elements. Methods in this interface support only read-only access to the list;
* read/write access is supported through the [MutableList] interface. * read/write access is supported through the [MutableList] interface.
* @param E the type of elements contained in the list. The list is covariant on its element type. * @param E the type of elements contained in the list. The list is covariant in its element type.
*/ */
public interface List<out E> : Collection<E> { public interface List<out E> : Collection<E> {
// Query Operations // Query Operations
@@ -190,7 +195,7 @@ public interface List<out E> : Collection<E> {
/** /**
* A generic ordered collection of elements that supports adding and removing elements. * A generic ordered collection of elements that supports adding and removing elements.
* @param E the type of elements contained in the list. The mutable list is invariant on its element type. * @param E the type of elements contained in the list. The mutable list is invariant in its element type.
*/ */
public interface MutableList<E> : List<E>, MutableCollection<E> { public interface MutableList<E> : List<E>, MutableCollection<E> {
// Modification Operations // Modification Operations
@@ -257,7 +262,7 @@ public interface MutableList<E> : List<E>, MutableCollection<E> {
* A generic unordered collection of elements that does not support duplicate elements. * A generic unordered collection of elements that does not support duplicate elements.
* Methods in this interface support only read-only access to the set; * Methods in this interface support only read-only access to the set;
* read/write access is supported through the [MutableSet] interface. * read/write access is supported through the [MutableSet] interface.
* @param E the type of elements contained in the set. The set is covariant on its element type. * @param E the type of elements contained in the set. The set is covariant in its element type.
*/ */
public interface Set<out E> : Collection<E> { public interface Set<out E> : Collection<E> {
// Query Operations // Query Operations
@@ -274,7 +279,7 @@ public interface Set<out E> : Collection<E> {
/** /**
* A generic unordered collection of elements that does not support duplicate elements, and supports * A generic unordered collection of elements that does not support duplicate elements, and supports
* adding and removing elements. * adding and removing elements.
* @param E the type of elements contained in the set. The mutable set is invariant on its element type. * @param E the type of elements contained in the set. The mutable set is invariant in its element type.
*/ */
public interface MutableSet<E> : Set<E>, MutableCollection<E> { public interface MutableSet<E> : Set<E>, MutableCollection<E> {
// Query Operations // Query Operations
@@ -304,9 +309,9 @@ public interface MutableSet<E> : Set<E>, MutableCollection<E> {
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key. * the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* Methods in this interface support only read-only access to the map; read-write access is supported through * Methods in this interface support only read-only access to the map; read-write access is supported through
* the [MutableMap] interface. * the [MutableMap] interface.
* @param K the type of map keys. The map is invariant on its key type, as it * @param K the type of map keys. The map is invariant in its key type, as it
* can accept key as a parameter (of [containsKey] for example) and return it in [keys] set. * can accept key as a parameter (of [containsKey] for example) and return it in [keys] set.
* @param V the type of map values. The map is covariant on its value type. * @param V the type of map values. The map is covariant in its value type.
*/ */
public interface Map<K, out V> { public interface Map<K, out V> {
// Query Operations // Query Operations
@@ -370,8 +375,8 @@ public interface Map<K, out V> {
/** /**
* A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving * A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key. * the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The mutable map is invariant on its value type. * @param V the type of map values. The mutable map is invariant in its value type.
*/ */
public interface MutableMap<K, V> : Map<K, V> { public interface MutableMap<K, V> : Map<K, V> {
// Modification Operations // Modification Operations
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -8,7 +8,7 @@ package kotlin.collections
/** /**
* Provides a skeletal implementation of the [MutableCollection] interface. * Provides a skeletal implementation of the [MutableCollection] interface.
* *
* @param E the type of elements contained in the collection. The collection is invariant on its element type. * @param E the type of elements contained in the collection. The collection is invariant in its element type.
*/ */
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : AbstractCollection<E>(), MutableCollection<E> { public actual abstract class AbstractMutableCollection<E> protected actual constructor() : AbstractCollection<E>(), MutableCollection<E> {
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
/* /*
* Based on GWT AbstractList * Based on GWT AbstractList
* Copyright 2007 Google Inc. * Copyright 2007 Google Inc.
@@ -13,7 +14,7 @@ package kotlin.collections
/** /**
* Provides a skeletal implementation of the [MutableList] interface. * Provides a skeletal implementation of the [MutableList] interface.
* *
* @param E the type of elements contained in the list. The list is invariant on its element type. * @param E the type of elements contained in the list. The list is invariant in its element type.
*/ */
public actual abstract class AbstractMutableList<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableList<E> { public actual abstract class AbstractMutableList<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableList<E> {
protected var modCount: Int = 0 protected var modCount: Int = 0
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
/* /*
* Based on GWT AbstractMap * Based on GWT AbstractMap
* Copyright 2007 Google Inc. * Copyright 2007 Google Inc.
@@ -14,8 +15,8 @@ package kotlin.collections
* *
* The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function. * The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function.
* *
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The map is invariant on its value type. * @param V the type of map values. The map is invariant in its value type.
*/ */
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : AbstractMap<K, V>(), MutableMap<K, V> { public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : AbstractMap<K, V>(), MutableMap<K, V> {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package kotlin.collections package kotlin.collections
@@ -7,7 +7,7 @@ package kotlin.collections
/** /**
* Provides a skeletal implementation of the [MutableSet] interface. * Provides a skeletal implementation of the [MutableSet] interface.
* *
* @param E the type of elements contained in the set. The set is invariant on its element type. * @param E the type of elements contained in the set. The set is invariant in its element type.
*/ */
public actual abstract class AbstractMutableSet<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableSet<E> { public actual abstract class AbstractMutableSet<E> protected actual constructor() : AbstractMutableCollection<E>(), MutableSet<E> {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -10,7 +10,7 @@ import java.util.AbstractCollection
/** /**
* Provides a skeletal implementation of the [MutableCollection] interface. * Provides a skeletal implementation of the [MutableCollection] interface.
* *
* @param E the type of elements contained in the collection. The collection is invariant on its element type. * @param E the type of elements contained in the collection. The collection is invariant in its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : MutableCollection<E>, AbstractCollection<E>() { public actual abstract class AbstractMutableCollection<E> protected actual constructor() : MutableCollection<E>, AbstractCollection<E>() {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -10,7 +10,7 @@ import java.util.AbstractList
/** /**
* Provides a skeletal implementation of the [MutableList] interface. * Provides a skeletal implementation of the [MutableList] interface.
* *
* @param E the type of elements contained in the list. The list is invariant on its element type. * @param E the type of elements contained in the list. The list is invariant in its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() { public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -12,8 +12,8 @@ import java.util.AbstractMap
* *
* The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function. * The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function.
* *
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The map is invariant on its value type. * @param V the type of map values. The map is invariant in its value type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : MutableMap<K, V>, AbstractMap<K, V>() { public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : MutableMap<K, V>, AbstractMap<K, V>() {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@@ -10,7 +10,7 @@ import java.util.AbstractSet
/** /**
* Provides a skeletal implementation of the [MutableSet] interface. * Provides a skeletal implementation of the [MutableSet] interface.
* *
* @param E the type of elements contained in the set. The set is invariant on its element type. * @param E the type of elements contained in the set. The set is invariant in its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public actual abstract class AbstractMutableSet<E> protected actual constructor() : MutableSet<E>, AbstractSet<E>() { public actual abstract class AbstractMutableSet<E> protected actual constructor() : MutableSet<E>, AbstractSet<E>() {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package kotlin.collections package kotlin.collections
@@ -9,7 +9,7 @@ import kotlin.js.JsName
/** /**
* Provides a skeletal implementation of the read-only [Collection] interface. * Provides a skeletal implementation of the read-only [Collection] interface.
* *
* @param E the type of elements contained in the collection. The collection is covariant on its element type. * @param E the type of elements contained in the collection. The collection is covariant in its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractCollection<out E> protected constructor() : Collection<E> { public abstract class AbstractCollection<out E> protected constructor() : Collection<E> {
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
/* /*
* Based on GWT AbstractList * Based on GWT AbstractList
* Copyright 2007 Google Inc. * Copyright 2007 Google Inc.
@@ -14,7 +15,7 @@ package kotlin.collections
* *
* This class is intended to help implementing read-only lists so it doesn't support concurrent modification tracking. * This class is intended to help implementing read-only lists so it doesn't support concurrent modification tracking.
* *
* @param E the type of elements contained in the list. The list is covariant on its element type. * @param E the type of elements contained in the list. The list is covariant in its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractList<out E> protected constructor() : AbstractCollection<E>(), List<E> { public abstract class AbstractList<out E> protected constructor() : AbstractCollection<E>(), List<E> {
@@ -1,7 +1,8 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
/* /*
* Based on GWT AbstractMap * Based on GWT AbstractMap
* Copyright 2007 Google Inc. * Copyright 2007 Google Inc.
@@ -14,8 +15,8 @@ package kotlin.collections
* *
* The implementor is required to implement [entries] property, which should return read-only set of map entries. * The implementor is required to implement [entries] property, which should return read-only set of map entries.
* *
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The map is covariant on its value type. * @param V the type of map values. The map is covariant in its value type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractMap<K, out V> protected constructor() : Map<K, V> { public abstract class AbstractMap<K, out V> protected constructor() : Map<K, V> {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package kotlin.collections package kotlin.collections
@@ -9,7 +9,7 @@ package kotlin.collections
* *
* This class is intended to help implementing read-only sets so it doesn't support concurrent modification tracking. * This class is intended to help implementing read-only sets so it doesn't support concurrent modification tracking.
* *
* @param E the type of elements contained in the set. The set is covariant on its element type. * @param E the type of elements contained in the set. The set is covariant in its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractSet<out E> protected constructor() : AbstractCollection<E>(), Set<E> { public abstract class AbstractSet<out E> protected constructor() : AbstractCollection<E>(), Set<E> {
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package kotlin.collections package kotlin.collections
@@ -21,7 +10,7 @@ import kotlin.internal.PlatformDependent
/** /**
* Classes that inherit from this interface can be represented as a sequence of elements that can * Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over. * be iterated over.
* @param T the type of element being iterated over. The iterator is covariant on its element type. * @param T the type of element being iterated over. The iterator is covariant in its element type.
*/ */
public interface Iterable<out T> { public interface Iterable<out T> {
/** /**
@@ -33,7 +22,7 @@ public interface Iterable<out T> {
/** /**
* Classes that inherit from this interface can be represented as a sequence of elements that can * Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over and that supports removing elements during iteration. * be iterated over and that supports removing elements during iteration.
* @param T the type of element being iterated over. The mutable iterator is invariant on its element type. * @param T the type of element being iterated over. The mutable iterator is invariant in its element type.
*/ */
public interface MutableIterable<out T> : Iterable<T> { public interface MutableIterable<out T> : Iterable<T> {
/** /**
@@ -45,7 +34,7 @@ public interface MutableIterable<out T> : Iterable<T> {
/** /**
* A generic collection of elements. Methods in this interface support only read-only access to the collection; * 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. * read/write access is supported through the [MutableCollection] interface.
* @param E the type of elements contained in the collection. The collection is covariant on its element type. * @param E the type of elements contained in the collection. The collection is covariant in its element type.
*/ */
public interface Collection<out E> : Iterable<E> { public interface Collection<out E> : Iterable<E> {
// Query Operations // Query Operations
@@ -76,7 +65,7 @@ public interface Collection<out E> : Iterable<E> {
/** /**
* A generic collection of elements that supports adding and removing elements. * A generic collection of elements that supports adding and removing elements.
* *
* @param E the type of elements contained in the collection. The mutable collection is invariant on its element type. * @param E the type of elements contained in the collection. The mutable collection is invariant in its element type.
*/ */
public interface MutableCollection<E> : Collection<E>, MutableIterable<E> { public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
// Query Operations // Query Operations
@@ -130,7 +119,7 @@ public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
/** /**
* A generic ordered collection of elements. Methods in this interface support only read-only access to the list; * A generic ordered collection of elements. Methods in this interface support only read-only access to the list;
* read/write access is supported through the [MutableList] interface. * read/write access is supported through the [MutableList] interface.
* @param E the type of elements contained in the list. The list is covariant on its element type. * @param E the type of elements contained in the list. The list is covariant in its element type.
*/ */
public interface List<out E> : Collection<E> { public interface List<out E> : Collection<E> {
// Query Operations // Query Operations
@@ -185,7 +174,7 @@ public interface List<out E> : Collection<E> {
/** /**
* A generic ordered collection of elements that supports adding and removing elements. * A generic ordered collection of elements that supports adding and removing elements.
* @param E the type of elements contained in the list. The mutable list is invariant on its element type. * @param E the type of elements contained in the list. The mutable list is invariant in its element type.
*/ */
public interface MutableList<E> : List<E>, MutableCollection<E> { public interface MutableList<E> : List<E>, MutableCollection<E> {
// Modification Operations // Modification Operations
@@ -252,7 +241,7 @@ public interface MutableList<E> : List<E>, MutableCollection<E> {
* A generic unordered collection of elements that does not support duplicate elements. * A generic unordered collection of elements that does not support duplicate elements.
* Methods in this interface support only read-only access to the set; * Methods in this interface support only read-only access to the set;
* read/write access is supported through the [MutableSet] interface. * read/write access is supported through the [MutableSet] interface.
* @param E the type of elements contained in the set. The set is covariant on its element type. * @param E the type of elements contained in the set. The set is covariant in its element type.
*/ */
public interface Set<out E> : Collection<E> { public interface Set<out E> : Collection<E> {
// Query Operations // Query Operations
@@ -269,7 +258,7 @@ public interface Set<out E> : Collection<E> {
/** /**
* A generic unordered collection of elements that does not support duplicate elements, and supports * A generic unordered collection of elements that does not support duplicate elements, and supports
* adding and removing elements. * adding and removing elements.
* @param E the type of elements contained in the set. The mutable set is invariant on its element type. * @param E the type of elements contained in the set. The mutable set is invariant in its element type.
*/ */
public interface MutableSet<E> : Set<E>, MutableCollection<E> { public interface MutableSet<E> : Set<E>, MutableCollection<E> {
// Query Operations // Query Operations
@@ -299,9 +288,9 @@ public interface MutableSet<E> : Set<E>, MutableCollection<E> {
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key. * the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* Methods in this interface support only read-only access to the map; read-write access is supported through * Methods in this interface support only read-only access to the map; read-write access is supported through
* the [MutableMap] interface. * the [MutableMap] interface.
* @param K the type of map keys. The map is invariant on its key type, as it * @param K the type of map keys. The map is invariant in its key type, as it
* can accept key as a parameter (of [containsKey] for example) and return it in [keys] set. * can accept key as a parameter (of [containsKey] for example) and return it in [keys] set.
* @param V the type of map values. The map is covariant on its value type. * @param V the type of map values. The map is covariant in its value type.
*/ */
public interface Map<K, out V> { public interface Map<K, out V> {
// Query Operations // Query Operations
@@ -377,8 +366,8 @@ public interface Map<K, out V> {
/** /**
* A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving * A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key. * the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* @param K the type of map keys. The map is invariant on its key type. * @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The mutable map is invariant on its value type. * @param V the type of map values. The mutable map is invariant in its value type.
*/ */
public interface MutableMap<K, V> : Map<K, V> { public interface MutableMap<K, V> : Map<K, V> {
// Modification Operations // Modification Operations