Remove java.util.* imports from common code.

This commit is contained in:
Ilya Gorbunov
2016-11-16 21:06:57 +03:00
parent b4fbedbc9e
commit 50cd620f92
21 changed files with 9 additions and 40 deletions
@@ -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)
/**
-1
View File
@@ -1,6 +1,5 @@
package test.comparisons
import java.util.*
import kotlin.test.*
import org.junit.Test
import kotlin.comparisons.*
@@ -18,7 +18,6 @@ package test.collections
import test.collections.behaviors.listBehavior
import test.comparisons.STRING_CASE_INSENSITIVE_ORDER
import java.util.*
import kotlin.test.*
import org.junit.Test as test
import kotlin.comparisons.*
@@ -16,7 +16,6 @@
package test.collections
import java.util.*
import kotlin.test.*
import org.junit.Test as test
import test.collections.behaviors.*
@@ -1,6 +1,5 @@
package test.collections
import java.util.*
import kotlin.test.*
import org.junit.Test as test
@@ -2,8 +2,6 @@ package test.collections
import kotlin.test.*
import java.util.*
import org.junit.Test as test
class MutableCollectionTest {
@@ -3,7 +3,6 @@ package test.collections
import org.junit.Test as test
import org.junit.Test
import kotlin.test.*
import java.util.*
import kotlin.comparisons.*
fun fibonacci(): Sequence<Int> {
-1
View File
@@ -18,7 +18,6 @@ package test.collections.js
import org.junit.Test as test
import kotlin.test.*
import java.util.*
class JsArrayTest {
-1
View File
@@ -2,7 +2,6 @@ package test.collections.js
import kotlin.test.*
import org.junit.Test as test
import java.util.*
import test.collections.*
import test.collections.behaviors.*
-1
View File
@@ -4,7 +4,6 @@ import kotlin.test.*
import org.junit.Test
import test.collections.*
import test.collections.behaviors.*
import java.util.*
class ComplexSetJsTest : SetJsTest() {
// Helper function with generic parameter to force to use ComlpexHashMap
+1 -2
View File
@@ -14,10 +14,9 @@
* limitations under the License.
*/
@file:JvmVersion
package test.collections.js
import java.util.*
public fun <V> stringMapOf(vararg pairs: Pair<String, V>): HashMap<String, V> = hashMapOf<String, V>(*pairs)
public fun <V> linkedStringMapOf(vararg pairs: Pair<String, V>): LinkedHashMap<String, V> = linkedMapOf(*pairs)
public fun stringSetOf(vararg elements: String): HashSet<String> = hashSetOf(*elements)
@@ -1,7 +1,5 @@
package test.properties.delegation.map
import java.util.*
import kotlin.properties.*
import kotlin.test.*
import org.junit.Test as test