[stdlib] Explicit visibility and return types: Collections
This commit is contained in:
committed by
Space Team
parent
0dd61c9f81
commit
aa4419b7e3
@@ -5,12 +5,12 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
expect class ArrayList<E> : MutableList<E>, RandomAccess {
|
||||
public expect class ArrayList<E> : MutableList<E>, RandomAccess {
|
||||
|
||||
/**
|
||||
* Creates a new empty [ArrayList].
|
||||
*/
|
||||
constructor()
|
||||
public constructor()
|
||||
|
||||
/**
|
||||
* Creates a new empty [ArrayList] with the specified initial capacity.
|
||||
@@ -24,17 +24,17 @@ expect class ArrayList<E> : MutableList<E>, RandomAccess {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
constructor(initialCapacity: Int)
|
||||
public constructor(initialCapacity: Int)
|
||||
|
||||
/**
|
||||
* Creates a new [ArrayList] filled with the elements of the specified collection.
|
||||
*
|
||||
* The iteration order of elements in the created list is the same as in the specified collection.
|
||||
*/
|
||||
constructor(elements: Collection<E>)
|
||||
public constructor(elements: Collection<E>)
|
||||
|
||||
fun trimToSize()
|
||||
fun ensureCapacity(minCapacity: Int)
|
||||
public fun trimToSize()
|
||||
public fun ensureCapacity(minCapacity: Int)
|
||||
|
||||
// From List
|
||||
|
||||
|
||||
@@ -5,28 +5,66 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
expect interface RandomAccess
|
||||
/**
|
||||
* Marker interface indicating that the [List] implementation supports fast indexed access.
|
||||
*/
|
||||
public expect interface RandomAccess
|
||||
|
||||
/**
|
||||
* Returns the array if it's not `null`, or an empty array otherwise.
|
||||
* @sample samples.collections.Arrays.Usage.arrayOrEmpty
|
||||
*/
|
||||
expect inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
|
||||
public expect inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
|
||||
|
||||
/**
|
||||
* Returns a *typed* array containing all the elements of this collection.
|
||||
*
|
||||
* Allocates an array of runtime type `T` having its size equal to the size of this collection
|
||||
* and populates the array with the elements of this collection.
|
||||
* @sample samples.collections.Collections.Collections.collectionToTypedArray
|
||||
*/
|
||||
public expect inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
|
||||
|
||||
expect inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
|
||||
|
||||
/**
|
||||
* Fills the list with the provided [value].
|
||||
*
|
||||
* Each element in the list gets replaced with the [value].
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
expect fun <T> MutableList<T>.fill(value: T): Unit
|
||||
public expect fun <T> MutableList<T>.fill(value: T): Unit
|
||||
|
||||
/**
|
||||
* Randomly shuffles elements in this list.
|
||||
*
|
||||
* See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
expect fun <T> MutableList<T>.shuffle(): Unit
|
||||
public expect fun <T> MutableList<T>.shuffle(): Unit
|
||||
|
||||
/**
|
||||
* Returns a new list with the elements of this collection randomly shuffled.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
expect fun <T> Iterable<T>.shuffled(): List<T>
|
||||
public expect fun <T> Iterable<T>.shuffled(): List<T>
|
||||
|
||||
expect fun <T : Comparable<T>> MutableList<T>.sort(): Unit
|
||||
expect fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
|
||||
/**
|
||||
* Sorts elements in the list in-place according to their natural sort order.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*
|
||||
* @sample samples.collections.Collections.Sorting.sortMutableList
|
||||
*/
|
||||
public expect fun <T : Comparable<T>> MutableList<T>.sort(): Unit
|
||||
|
||||
|
||||
/**
|
||||
* Sorts elements in the list in-place according to the order specified with [comparator].
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*
|
||||
* @sample samples.collections.Collections.Sorting.sortMutableListWith
|
||||
*/
|
||||
public expect fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
|
||||
|
||||
|
||||
// from Grouping.kt
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
expect class HashMap<K, V> : MutableMap<K, V> {
|
||||
public expect class HashMap<K, V> : MutableMap<K, V> {
|
||||
/**
|
||||
* Creates a new empty [HashMap].
|
||||
*/
|
||||
constructor()
|
||||
public constructor()
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashMap] with the specified initial capacity.
|
||||
@@ -23,7 +23,7 @@ expect class HashMap<K, V> : MutableMap<K, V> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
constructor(initialCapacity: Int)
|
||||
public constructor(initialCapacity: Int)
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashMap] with the specified initial capacity and load factor.
|
||||
@@ -39,12 +39,12 @@ expect class HashMap<K, V> : MutableMap<K, V> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
constructor(initialCapacity: Int, loadFactor: Float)
|
||||
public constructor(initialCapacity: Int, loadFactor: Float)
|
||||
|
||||
/**
|
||||
* Creates a new [HashMap] filled with the contents of the specified [original] map.
|
||||
*/
|
||||
constructor(original: Map<out K, V>)
|
||||
public constructor(original: Map<out K, V>)
|
||||
|
||||
// From Map
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
expect class HashSet<E> : MutableSet<E> {
|
||||
public expect class HashSet<E> : MutableSet<E> {
|
||||
/**
|
||||
* Creates a new empty [HashSet].
|
||||
*/
|
||||
constructor()
|
||||
public constructor()
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashSet] with the specified initial capacity.
|
||||
@@ -23,7 +23,7 @@ expect class HashSet<E> : MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
constructor(initialCapacity: Int)
|
||||
public constructor(initialCapacity: Int)
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashSet] with the specified initial capacity and load factor.
|
||||
@@ -39,12 +39,12 @@ expect class HashSet<E> : MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
constructor(initialCapacity: Int, loadFactor: Float)
|
||||
public constructor(initialCapacity: Int, loadFactor: Float)
|
||||
|
||||
/**
|
||||
* Creates a new [HashSet] filled with the elements of the specified collection.
|
||||
*/
|
||||
constructor(elements: Collection<E>)
|
||||
public constructor(elements: Collection<E>)
|
||||
|
||||
// From Set
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
expect class LinkedHashMap<K, V> : MutableMap<K, V> {
|
||||
public expect class LinkedHashMap<K, V> : MutableMap<K, V> {
|
||||
/**
|
||||
* Creates a new empty [LinkedHashMap].
|
||||
*/
|
||||
constructor()
|
||||
public constructor()
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashMap] with the specified initial capacity.
|
||||
@@ -23,7 +23,7 @@ expect class LinkedHashMap<K, V> : MutableMap<K, V> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
constructor(initialCapacity: Int)
|
||||
public constructor(initialCapacity: Int)
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashMap] with the specified initial capacity and load factor.
|
||||
@@ -39,14 +39,14 @@ expect class LinkedHashMap<K, V> : MutableMap<K, V> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
constructor(initialCapacity: Int, loadFactor: Float)
|
||||
public constructor(initialCapacity: Int, loadFactor: Float)
|
||||
|
||||
/**
|
||||
* Creates a new [LinkedHashMap] filled with the contents of the specified [original] map.
|
||||
*
|
||||
* The iteration order of entries in the created map is the same as in the [original] map.
|
||||
*/
|
||||
constructor(original: Map<out K, V>)
|
||||
public constructor(original: Map<out K, V>)
|
||||
|
||||
// From Map
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
expect class LinkedHashSet<E> : MutableSet<E> {
|
||||
public expect class LinkedHashSet<E> : MutableSet<E> {
|
||||
/**
|
||||
* Creates a new empty [LinkedHashSet].
|
||||
*/
|
||||
constructor()
|
||||
public constructor()
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashSet] with the specified initial capacity.
|
||||
@@ -23,7 +23,7 @@ expect class LinkedHashSet<E> : MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
constructor(initialCapacity: Int)
|
||||
public constructor(initialCapacity: Int)
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashSet] with the specified initial capacity and load factor.
|
||||
@@ -39,14 +39,14 @@ expect class LinkedHashSet<E> : MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
constructor(initialCapacity: Int, loadFactor: Float)
|
||||
public constructor(initialCapacity: Int, loadFactor: Float)
|
||||
|
||||
/**
|
||||
* Creates a new [LinkedHashSet] filled with the elements of the specified collection.
|
||||
*
|
||||
* The iteration order of elements in the created set is the same as in the specified collection.
|
||||
*/
|
||||
constructor(elements: Collection<E>)
|
||||
public constructor(elements: Collection<E>)
|
||||
|
||||
// From Set
|
||||
|
||||
|
||||
Reference in New Issue
Block a user