KDoc for mutable abstract collections.

Document abstract overrides.
This commit is contained in:
Ilya Gorbunov
2016-10-21 23:11:46 +03:00
parent ef5e53b37b
commit fc7b1c8611
8 changed files with 112 additions and 1 deletions
@@ -16,7 +16,11 @@
package kotlin.collections
/**
* 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.
*/
public abstract class AbstractMutableCollection<E> protected constructor() : AbstractCollection<E>(), MutableCollection<E> {
abstract override fun add(element: E): Boolean
@@ -21,6 +21,11 @@
package kotlin.collections
/**
* 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.
*/
public abstract class AbstractMutableList<E> protected constructor() : AbstractMutableCollection<E>(), MutableList<E> {
protected var modCount: Int = 0
@@ -79,6 +84,9 @@ public abstract class AbstractMutableList<E> protected constructor() : AbstractM
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E> = SubList(this, fromIndex, toIndex)
/**
* Removes the range of elements from this list starting from [fromIndex] and ending with but not including [toIndex].
*/
protected open fun removeRange(fromIndex: Int, toIndex: Int) {
val iterator = listIterator(fromIndex)
repeat(toIndex - fromIndex) {
@@ -87,6 +95,11 @@ public abstract class AbstractMutableList<E> protected constructor() : AbstractM
}
}
/**
* Compares this list with another list instance with the ordered structural equality.
*
* @return true, if [other] instance is a [List] of the same size, which contains the same elements in the same order.
*/
override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is List<*>) return false
@@ -94,6 +107,9 @@ public abstract class AbstractMutableList<E> protected constructor() : AbstractM
return AbstractList.orderedEquals(this, other)
}
/**
* Returns the hash code value for this list.
*/
override fun hashCode(): Int = AbstractList.orderedHashCode(this)
@@ -20,6 +20,14 @@
package kotlin.collections
/**
* Provides a skeletal implementation of the [MutableMap] interface.
*
* The implementor is required to implement the [entries] property, which should return mutable set of map entries, and the [put] function.
*
* @param K the type of map keys. The map is invariant on its key type.
* @param V the type of map values. The map is invariant on its value type.
*/
public abstract class AbstractMutableMap<K, V> protected constructor() : AbstractMap<K, V>(), MutableMap<K, V> {
/**
@@ -15,14 +15,27 @@
*/
package kotlin.collections
/**
* 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.
*/
public abstract class AbstractMutableSet<E> protected constructor() : AbstractMutableCollection<E>(), MutableSet<E> {
/**
* Compares this set with another set instance with the unordered structural equality.
*
* @return true, if [other] instance is a [Set] of the same size, all elements of which are contained in this set.
*/
override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is Set<*>) return false
return AbstractSet.setEquals(this, other)
}
/**
* Returns the hash code value for this set.
*/
override fun hashCode(): Int = AbstractSet.unorderedHashCode(this)
}