Adjust stdlib to size transformation

This commit is contained in:
Denis Zharkov
2015-10-06 14:31:19 +03:00
parent 7b432e4830
commit 61416b3d14
12 changed files with 28 additions and 28 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ package org.w3c.dom
import java.util.AbstractList
private class HTMLCollectionListView(val collection: HTMLCollection) : AbstractList<HTMLElement>() {
override fun size(): Int = collection.length
override val size: Int get() = collection.length
override fun get(index: Int): HTMLElement =
when {
@@ -32,7 +32,7 @@ public fun HTMLCollection.asList(): List<HTMLElement> = HTMLCollectionListView(t
public fun HTMLCollection?.toElementList(): List<Element> = this?.asList() ?: emptyList()
private class DOMTokenListView(val delegate: DOMTokenList) : AbstractList<String>() {
override fun size(): Int = delegate.length
override val size: Int get() = delegate.length
override fun get(index: Int) =
when {
+7 -7
View File
@@ -26,7 +26,7 @@ public abstract class AbstractCollection<E>() : MutableCollection<E> {
override fun retainAll(c: Collection<Any?>): Boolean = noImpl
override fun clear(): Unit = noImpl
abstract override fun size(): Int
abstract override val size: Int
override fun hashCode(): Int = noImpl
override fun equals(other: Any?): Boolean = noImpl
@@ -51,7 +51,7 @@ public abstract class AbstractList<E>() : AbstractCollection<E>(), MutableList<E
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E> = noImpl
override fun size(): Int = noImpl
override val size: Int get() = noImpl
override fun equals(other: Any?): Boolean = noImpl
@@ -61,7 +61,7 @@ public abstract class AbstractList<E>() : AbstractCollection<E>(), MutableList<E
@library
public open class ArrayList<E>(capacity: Int = 0) : AbstractList<E>() {
override fun get(index: Int): E = noImpl
override fun size(): Int = noImpl
override val size: Int get() = noImpl
}
@library
@@ -81,7 +81,7 @@ public open class LinkedList<E>() : AbstractList<E>() {
public open class HashSet<E>(
initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR
) : AbstractCollection<E>(), MutableSet<E> {
override fun size(): Int = noImpl
override val size: Int get() = noImpl
}
@library
@@ -90,19 +90,19 @@ public interface SortedSet<E> : Set<E> {
@library
public open class TreeSet<E>() : AbstractCollection<E>(), MutableSet<E>, SortedSet<E> {
override fun size(): Int = noImpl
override val size: Int get() = noImpl
}
@library
public open class LinkedHashSet<E>(
initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR
) : HashSet<E>(initialCapacity, loadFactor), MutableSet<E> {
override fun size(): Int = noImpl
override val size: Int get() = noImpl
}
@library
public open class HashMap<K, V>(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap<K, V> {
override fun size(): Int = noImpl
override val size: Int get() = noImpl
override fun isEmpty(): Boolean = noImpl
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
override fun get(key: Any?): V? = noImpl
+1 -1
View File
@@ -177,7 +177,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? {
get() = match[0]!!
override val groups: MatchGroupCollection = object : MatchGroupCollection {
override fun size(): Int = match.size()
override val size: Int get() = match.size()
override fun isEmpty(): Boolean = size() == 0
override fun contains(o: Any?): Boolean = this.any { it == o }
+8 -8
View File
@@ -10445,7 +10445,7 @@ public fun <T> Array<out T>.asList(): List<T> {
@kotlin.jvm.JvmVersion
public fun BooleanArray.asList(): List<Boolean> {
return object : AbstractList<Boolean>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Boolean)
override fun iterator(): MutableIterator<Boolean> = this@asList.iterator() as MutableIterator<Boolean>
@@ -10461,7 +10461,7 @@ public fun BooleanArray.asList(): List<Boolean> {
@kotlin.jvm.JvmVersion
public fun ByteArray.asList(): List<Byte> {
return object : AbstractList<Byte>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Byte)
override fun iterator(): MutableIterator<Byte> = this@asList.iterator() as MutableIterator<Byte>
@@ -10477,7 +10477,7 @@ public fun ByteArray.asList(): List<Byte> {
@kotlin.jvm.JvmVersion
public fun CharArray.asList(): List<Char> {
return object : AbstractList<Char>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Char)
override fun iterator(): MutableIterator<Char> = this@asList.iterator() as MutableIterator<Char>
@@ -10493,7 +10493,7 @@ public fun CharArray.asList(): List<Char> {
@kotlin.jvm.JvmVersion
public fun DoubleArray.asList(): List<Double> {
return object : AbstractList<Double>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Double)
override fun iterator(): MutableIterator<Double> = this@asList.iterator() as MutableIterator<Double>
@@ -10509,7 +10509,7 @@ public fun DoubleArray.asList(): List<Double> {
@kotlin.jvm.JvmVersion
public fun FloatArray.asList(): List<Float> {
return object : AbstractList<Float>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Float)
override fun iterator(): MutableIterator<Float> = this@asList.iterator() as MutableIterator<Float>
@@ -10525,7 +10525,7 @@ public fun FloatArray.asList(): List<Float> {
@kotlin.jvm.JvmVersion
public fun IntArray.asList(): List<Int> {
return object : AbstractList<Int>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Int)
override fun iterator(): MutableIterator<Int> = this@asList.iterator() as MutableIterator<Int>
@@ -10541,7 +10541,7 @@ public fun IntArray.asList(): List<Int> {
@kotlin.jvm.JvmVersion
public fun LongArray.asList(): List<Long> {
return object : AbstractList<Long>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Long)
override fun iterator(): MutableIterator<Long> = this@asList.iterator() as MutableIterator<Long>
@@ -10557,7 +10557,7 @@ public fun LongArray.asList(): List<Long> {
@kotlin.jvm.JvmVersion
public fun ShortArray.asList(): List<Short> {
return object : AbstractList<Short>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as Short)
override fun iterator(): MutableIterator<Short> = this@asList.iterator() as MutableIterator<Short>
@@ -20,7 +20,7 @@ internal object EmptyList : List<Nothing>, Serializable {
override fun hashCode(): Int = 1
override fun toString(): String = "[]"
override fun size(): Int = 0
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun contains(o: Any?): Boolean = false
override fun containsAll(c: Collection<Any?>): Boolean = c.isEmpty()
@@ -65,7 +65,7 @@ private class MapWithDefaultImpl<K, out V>(public override val map: Map<K,V>, pr
override fun equals(other: Any?): Boolean = map.equals(other)
override fun hashCode(): Int = map.hashCode()
override fun toString(): String = map.toString()
override fun size(): Int = map.size()
override val size: Int get() = map.size()
override fun isEmpty(): Boolean = map.isEmpty()
override fun containsKey(key: Any?): Boolean = map.containsKey(key)
override fun containsValue(value: Any?): Boolean = map.containsValue(value)
@@ -81,7 +81,7 @@ private class MutableMapWithDefaultImpl<K, V>(public override val map: MutableMa
override fun equals(other: Any?): Boolean = map.equals(other)
override fun hashCode(): Int = map.hashCode()
override fun toString(): String = map.toString()
override fun size(): Int = map.size()
override val size: Int get() = map.size()
override fun isEmpty(): Boolean = map.isEmpty()
override fun containsKey(key: Any?): Boolean = map.containsKey(key)
override fun containsValue(value: Any?): Boolean = map.containsValue(value)
@@ -11,7 +11,7 @@ private object EmptyMap : Map<Any, Nothing>, Serializable {
override fun hashCode(): Int = 0
override fun toString(): String = "{}"
override fun size(): Int = 0
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun containsKey(key: Any?): Boolean = false
@@ -22,7 +22,7 @@ import java.util.AbstractList
import kotlin.platform.platformName
private open class ReversedListReadOnly<T>(protected open val delegate: List<T>) : AbstractList<T>() {
override fun size(): Int = delegate.size()
override val size: Int get() = delegate.size()
override fun get(index: Int): T = delegate[index.flipIndex()]
protected fun Int.flipIndex(): Int = if (this in 0..size() - 1) size() - this - 1 else throw IndexOutOfBoundsException("index $this should be in range [${0..size() - 1}]")
@@ -12,7 +12,7 @@ internal object EmptySet : Set<Nothing>, Serializable {
override fun hashCode(): Int = 0
override fun toString(): String = "[]"
override fun size(): Int = 0
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun contains(o: Any?): Boolean = false
override fun containsAll(c: Collection<Any?>): Boolean = c.isEmpty()
+2 -2
View File
@@ -211,7 +211,7 @@ public fun Node.removeFromParent() {
}
private class NodeListAsList(private val delegate: NodeList) : AbstractList<Node>() {
override fun size(): Int = delegate.length
override val size: Int get() = delegate.length
override fun get(index: Int): Node = when {
index in 0..size() - 1 -> delegate.item(index)!!
@@ -231,7 +231,7 @@ private class ElementListAsList(private val nodeList: NodeList) : AbstractList<E
}
}
override fun size(): Int = nodeList.length
override val size: Int get() = nodeList.length
}
@@ -230,7 +230,7 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input
get() = matchResult.group()
override val groups: MatchGroupCollection = object : MatchGroupCollection {
override fun size(): Int = matchResult.groupCount() + 1
override val size: Int get() = matchResult.groupCount() + 1
override fun isEmpty(): Boolean = false
override fun contains(o: Any?): Boolean = o is MatchGroup? && this.any({ it == o })
override fun containsAll(c: Collection<Any?>): Boolean = c.all({contains(it)})
@@ -228,7 +228,7 @@ fun specialJVM(): List<GenericFunction> {
body(ArraysOfPrimitives) {
"""
return object : AbstractList<T>(), RandomAccess {
override fun size(): Int = this@asList.size()
override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: Any?): Boolean = this@asList.contains(o as T)
override fun iterator(): MutableIterator<T> = this@asList.iterator() as MutableIterator<T>