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
+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(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"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
* 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> {
/**
@@ -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
* 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> {
/**
@@ -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;
* 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> {
// Query Operations
@@ -81,7 +86,7 @@ public interface Collection<out E> : Iterable<E> {
/**
* 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> {
// 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;
* 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> {
// 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.
* @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> {
// 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.
* Methods in this interface support only read-only access to the set;
* 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> {
// 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
* 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> {
// 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.
* Methods in this interface support only read-only access to the map; read-write access is supported through
* 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.
* @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> {
// 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
* 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 V the type of map values. The mutable map is invariant on its value 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 in its value type.
*/
public interface MutableMap<K, V> : Map<K, V> {
// Modification Operations