Minor: reorder families in generated code.

This commit is contained in:
Ilya Gorbunov
2016-02-02 00:50:17 +03:00
parent 477b57cdfd
commit 7a50562a4e
2 changed files with 46 additions and 46 deletions
+41 -41
View File
@@ -994,18 +994,18 @@ public inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun <T> Collection<T>.toArrayList(): ArrayList<T> {
return ArrayList(this)
public fun <T> Iterable<T>.toArrayList(): ArrayList<T> {
if (this is Collection<T>)
return ArrayList(this)
return toCollection(ArrayList<T>())
}
/**
* Returns an [ArrayList] of all elements.
*/
@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR)
public fun <T> Iterable<T>.toArrayList(): ArrayList<T> {
if (this is Collection<T>)
return ArrayList(this)
return toCollection(ArrayList<T>())
public fun <T> Collection<T>.toArrayList(): ArrayList<T> {
return ArrayList(this)
}
/**
@@ -1060,17 +1060,17 @@ public inline fun <T, K, V> Iterable<T>.toMapBy(selector: (T) -> K, transform: (
/**
* Returns a [MutableList] filled with all elements of this collection.
*/
public fun <T> Collection<T>.toMutableList(): MutableList<T> {
return ArrayList(this)
public fun <T> Iterable<T>.toMutableList(): MutableList<T> {
if (this is Collection<T>)
return this.toMutableList()
return toCollection(ArrayList<T>())
}
/**
* Returns a [MutableList] filled with all elements of this collection.
*/
public fun <T> Iterable<T>.toMutableList(): MutableList<T> {
if (this is Collection<T>)
return this.toMutableList()
return toCollection(ArrayList<T>())
public fun <T> Collection<T>.toMutableList(): MutableList<T> {
return ArrayList(this)
}
/**
@@ -1332,18 +1332,18 @@ public inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean {
/**
* Returns the number of elements in this collection.
*/
@kotlin.internal.InlineOnly
public inline fun <T> Collection<T>.count(): Int {
return size
public fun <T> Iterable<T>.count(): Int {
var count = 0
for (element in this) count++
return count
}
/**
* Returns the number of elements in this collection.
*/
public fun <T> Iterable<T>.count(): Int {
var count = 0
for (element in this) count++
return count
@kotlin.internal.InlineOnly
public inline fun <T> Collection<T>.count(): Int {
return size
}
/**
@@ -1696,8 +1696,9 @@ public inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean): Pair<Lis
/**
* Returns a list containing all elements of the original collection and then the given [element].
*/
public operator fun <T> Collection<T>.plus(element: T): List<T> {
val result = ArrayList<T>(size + 1)
public operator fun <T> Iterable<T>.plus(element: T): List<T> {
if (this is Collection) return this.plus(element)
val result = ArrayList<T>()
result.addAll(this)
result.add(element)
return result
@@ -1706,14 +1707,24 @@ public operator fun <T> Collection<T>.plus(element: T): List<T> {
/**
* Returns a list containing all elements of the original collection and then the given [element].
*/
public operator fun <T> Iterable<T>.plus(element: T): List<T> {
if (this is Collection) return this.plus(element)
val result = ArrayList<T>()
public operator fun <T> Collection<T>.plus(element: T): List<T> {
val result = ArrayList<T>(size + 1)
result.addAll(this)
result.add(element)
return result
}
/**
* Returns a list containing all elements of the original collection and then all elements of the given [elements] array.
*/
public operator fun <T> Iterable<T>.plus(elements: Array<out T>): List<T> {
if (this is Collection) return this.plus(elements)
val result = ArrayList<T>()
result.addAll(this)
result.addAll(elements)
return result
}
/**
* Returns a list containing all elements of the original collection and then all elements of the given [elements] array.
*/
@@ -1725,9 +1736,9 @@ public operator fun <T> Collection<T>.plus(elements: Array<out T>): List<T> {
}
/**
* Returns a list containing all elements of the original collection and then all elements of the given [elements] array.
* Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.
*/
public operator fun <T> Iterable<T>.plus(elements: Array<out T>): List<T> {
public operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {
if (this is Collection) return this.plus(elements)
val result = ArrayList<T>()
result.addAll(this)
@@ -1752,10 +1763,9 @@ public operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> {
}
/**
* Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.
* Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.
*/
public operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {
if (this is Collection) return this.plus(elements)
public operator fun <T> Iterable<T>.plus(elements: Sequence<T>): List<T> {
val result = ArrayList<T>()
result.addAll(this)
result.addAll(elements)
@@ -1772,21 +1782,11 @@ public operator fun <T> Collection<T>.plus(elements: Sequence<T>): List<T> {
return result
}
/**
* Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.
*/
public operator fun <T> Iterable<T>.plus(elements: Sequence<T>): List<T> {
val result = ArrayList<T>()
result.addAll(this)
result.addAll(elements)
return result
}
/**
* Returns a list containing all elements of the original collection and then the given [element].
*/
@kotlin.internal.InlineOnly
public inline fun <T> Collection<T>.plusElement(element: T): List<T> {
public inline fun <T> Iterable<T>.plusElement(element: T): List<T> {
return plus(element)
}
@@ -1794,7 +1794,7 @@ public inline fun <T> Collection<T>.plusElement(element: T): List<T> {
* Returns a list containing all elements of the original collection and then the given [element].
*/
@kotlin.internal.InlineOnly
public inline fun <T> Iterable<T>.plusElement(element: T): List<T> {
public inline fun <T> Collection<T>.plusElement(element: T): List<T> {
return plus(element)
}
@@ -6,22 +6,22 @@ import java.io.StringReader
import java.util.*
enum class Family {
Sequences,
Iterables,
Collections,
Lists,
Maps,
Sets,
Maps,
InvariantArraysOfObjects,
ArraysOfObjects,
ArraysOfPrimitives,
Sequences,
CharSequences,
Strings,
Ranges,
RangesOfPrimitives,
ProgressionsOfPrimitives,
Primitives,
Generic;
Generic,
Primitives;
val isPrimitiveSpecialization: Boolean by lazy { this in primitiveSpecializations }
@@ -199,7 +199,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
fun instantiate(vararg families: Family = Family.values()): List<ConcreteFunction> {
return families
.sortedBy { if (it == InvariantArraysOfObjects) "ArraysOfObjectsInvariant" else it.name }
.sortedBy { it.ordinal }
.filter { buildFamilies.contains(it) }
.flatMap { family -> instantiate(family) }
}