Remove java.util.* imports from common code.
This commit is contained in:
@@ -20,8 +20,6 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
|
||||
|
||||
/** Returns the array if it's not `null`, or an empty array otherwise. */
|
||||
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
import kotlin.comparisons.compareValues
|
||||
|
||||
internal object EmptyIterator : ListIterator<Nothing> {
|
||||
@@ -89,7 +88,7 @@ public inline fun <T> listOf(): List<T> = emptyList()
|
||||
* The returned list is serializable.
|
||||
*/
|
||||
@JvmVersion
|
||||
public fun <T> listOf(element: T): List<T> = Collections.singletonList(element)
|
||||
public fun <T> listOf(element: T): List<T> = java.util.Collections.singletonList(element)
|
||||
|
||||
/** Returns a new [MutableList] with the given elements. */
|
||||
public fun <T> mutableListOf(vararg elements: T): MutableList<T>
|
||||
@@ -137,7 +136,7 @@ public inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()
|
||||
*/
|
||||
@JvmVersion
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Enumeration<T>.toList(): List<T> = Collections.list(this)
|
||||
public inline fun <T> java.util.Enumeration<T>.toList(): List<T> = java.util.Collections.list(this)
|
||||
|
||||
/**
|
||||
* Checks if all elements in the specified collection are contained in this collection.
|
||||
@@ -160,7 +159,7 @@ private fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<Any?> =
|
||||
// if the array came from varargs and already is array of Any, copying isn't required
|
||||
@Suppress("UNCHECKED_CAST") (this as Array<Any?>)
|
||||
else
|
||||
Arrays.copyOf(this, this.size, Array<Any?>::class.java)
|
||||
java.util.Arrays.copyOf(this, this.size, Array<Any?>::class.java)
|
||||
|
||||
/**
|
||||
* Searches this list or its range for the provided [element] using the binary search algorithm.
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Creates an [Iterator] for an [Enumeration], allowing to use it in `for` loops.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun <T> Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> {
|
||||
public operator fun <T> java.util.Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> {
|
||||
override fun hasNext(): Boolean = hasMoreElements()
|
||||
|
||||
public override fun next(): T = nextElement()
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Returns the value for the given key, or the implicit default value for this map.
|
||||
* By default no implicit value is provided for maps and a [NoSuchElementException] is thrown.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
|
||||
private object EmptyMap : Map<Any?, Nothing>, Serializable {
|
||||
private const val serialVersionUID: Long = 8246714829545688274
|
||||
|
||||
@@ -47,7 +45,7 @@ public inline fun <K, V> mapOf(): Map<K, V> = emptyMap()
|
||||
* specified value. The returned map is serializable.
|
||||
*/
|
||||
@JvmVersion
|
||||
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = Collections.singletonMap(pair.first, pair.second)
|
||||
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = java.util.Collections.singletonMap(pair.first, pair.second)
|
||||
|
||||
/**
|
||||
* Returns a new [MutableMap] with the specified contents, given as a list of pairs
|
||||
@@ -568,4 +566,4 @@ internal inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = toSingl
|
||||
// creates a singleton copy of map
|
||||
@kotlin.jvm.JvmVersion
|
||||
internal fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V>
|
||||
= with (entries.iterator().next()) { Collections.singletonMap(key, value) }
|
||||
= with (entries.iterator().next()) { java.util.Collections.singletonMap(key, value) }
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Removes a single instance of the specified element from this
|
||||
* collection, if it is present.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
package kotlin.sequences
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Given an [iterator] function constructs a [Sequence] that returns values through the [Iterator]
|
||||
* provided by that function.
|
||||
@@ -25,7 +23,7 @@ public fun <T> Iterator<T>.asSequence(): Sequence<T> = Sequence { this }.constra
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun<T> Enumeration<T>.asSequence(): Sequence<T> = this.iterator().asSequence()
|
||||
public inline fun<T> java.util.Enumeration<T>.asSequence(): Sequence<T> = this.iterator().asSequence()
|
||||
|
||||
/**
|
||||
* Creates a sequence that returns the specified values.
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.*
|
||||
|
||||
|
||||
internal object EmptySet : Set<Nothing>, Serializable {
|
||||
private const val serialVersionUID: Long = 3406603774387020532
|
||||
@@ -61,7 +59,7 @@ public inline fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet()
|
||||
* The returned set is serializable.
|
||||
*/
|
||||
@JvmVersion
|
||||
public fun <T> setOf(element: T): Set<T> = Collections.singleton(element)
|
||||
public fun <T> setOf(element: T): Set<T> = java.util.Collections.singleton(element)
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user