Rename operand parameter of plus and minus for collections
This commit is contained in:
@@ -11150,213 +11150,6 @@ public fun <C : MutableCollection<in R>, R> Array<*>.filterIsInstanceTo(destinat
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun BooleanArray.plus(array: BooleanArray): BooleanArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ByteArray.plus(array: ByteArray): ByteArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun CharArray.plus(array: CharArray): CharArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun DoubleArray.plus(array: DoubleArray): DoubleArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun FloatArray.plus(array: FloatArray): FloatArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun IntArray.plus(array: IntArray): IntArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun LongArray.plus(array: LongArray): LongArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ShortArray.plus(array: ShortArray): ShortArray {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [array].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun <T> Array<T>.plus(array: Array<out T>): Array<T> {
|
||||
val thisSize = size
|
||||
val arraySize = array.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(array, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun BooleanArray.plus(collection: Collection<Boolean>): BooleanArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ByteArray.plus(collection: Collection<Byte>): ByteArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun CharArray.plus(collection: Collection<Char>): CharArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun DoubleArray.plus(collection: Collection<Double>): DoubleArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun FloatArray.plus(collection: Collection<Float>): FloatArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun IntArray.plus(collection: Collection<Int>): IntArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun LongArray.plus(collection: Collection<Long>): LongArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ShortArray.plus(collection: Collection<Short>): ShortArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [collection].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun <T> Array<T>.plus(collection: Collection<T>): Array<T> {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + collection.size)
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@@ -11456,6 +11249,213 @@ public operator fun <T> Array<T>.plus(element: T): Array<T> {
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun BooleanArray.plus(elements: Collection<Boolean>): BooleanArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ByteArray.plus(elements: Collection<Byte>): ByteArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun CharArray.plus(elements: Collection<Char>): CharArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun FloatArray.plus(elements: Collection<Float>): FloatArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun IntArray.plus(elements: Collection<Int>): IntArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun LongArray.plus(elements: Collection<Long>): LongArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ShortArray.plus(elements: Collection<Short>): ShortArray {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun <T> Array<T>.plus(elements: Collection<T>): Array<T> {
|
||||
var index = size
|
||||
val result = Arrays.copyOf(this, index + elements.size)
|
||||
for (element in elements) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ByteArray.plus(elements: ByteArray): ByteArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun CharArray.plus(elements: CharArray): CharArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun FloatArray.plus(elements: FloatArray): FloatArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun IntArray.plus(elements: IntArray): IntArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun LongArray.plus(elements: LongArray): LongArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun ShortArray.plus(elements: ShortArray): ShortArray {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public operator fun <T> Array<T>.plus(elements: Array<out T>): Array<T> {
|
||||
val thisSize = size
|
||||
val arraySize = elements.size
|
||||
val result = Arrays.copyOf(this, thisSize + arraySize)
|
||||
System.arraycopy(elements, 0, result, thisSize, arraySize)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
|
||||
@@ -1493,25 +1493,6 @@ public fun <T : Any> List<T?>.requireNoNulls(): List<T> {
|
||||
return this as List<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection except the elements contained in the given [array].
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.minus(array: Array<out T>): List<T> {
|
||||
if (array.isEmpty()) return this.toList()
|
||||
val other = array.toHashSet()
|
||||
return this.filterNot { it in other }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection except the elements contained in the given [collection].
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.minus(collection: Iterable<T>): List<T> {
|
||||
val other = collection.convertToSetForSetOperationWith(this)
|
||||
if (other.isEmpty())
|
||||
return this.toList()
|
||||
return this.filterNot { it in other }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection without the first occurrence of the given [element].
|
||||
*/
|
||||
@@ -1522,10 +1503,29 @@ public operator fun <T> Iterable<T>.minus(element: T): List<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection except the elements contained in the given [sequence].
|
||||
* Returns a list containing all elements of the original collection except the elements contained in the given [elements] array.
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.minus(sequence: Sequence<T>): List<T> {
|
||||
val other = sequence.toHashSet()
|
||||
public operator fun <T> Iterable<T>.minus(elements: Array<out T>): List<T> {
|
||||
if (elements.isEmpty()) return this.toList()
|
||||
val other = elements.toHashSet()
|
||||
return this.filterNot { it in other }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection except the elements contained in the given [elements] collection.
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.minus(elements: Iterable<T>): List<T> {
|
||||
val other = elements.convertToSetForSetOperationWith(this)
|
||||
if (other.isEmpty())
|
||||
return this.toList()
|
||||
return this.filterNot { it in other }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection except the elements contained in the given [elements] sequence.
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.minus(elements: Sequence<T>): List<T> {
|
||||
val other = elements.toHashSet()
|
||||
if (other.isEmpty())
|
||||
return this.toList()
|
||||
return this.filterNot { it in other }
|
||||
@@ -1549,54 +1549,6 @@ public inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean): Pair<Lis
|
||||
return Pair(first, second)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [array].
|
||||
*/
|
||||
public operator fun <T> Collection<T>.plus(array: Array<out T>): List<T> {
|
||||
val result = ArrayList<T>(this.size + array.size)
|
||||
result.addAll(this)
|
||||
result.addAll(array)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [array].
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.plus(array: Array<out T>): List<T> {
|
||||
if (this is Collection) return this.plus(array)
|
||||
val result = ArrayList<T>()
|
||||
result.addAll(this)
|
||||
result.addAll(array)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [collection].
|
||||
*/
|
||||
public operator fun <T> Collection<T>.plus(collection: Iterable<T>): List<T> {
|
||||
if (collection is Collection) {
|
||||
val result = ArrayList<T>(this.size + collection.size)
|
||||
result.addAll(this)
|
||||
result.addAll(collection)
|
||||
return result
|
||||
} else {
|
||||
val result = ArrayList<T>(this)
|
||||
result.addAll(collection)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [collection].
|
||||
*/
|
||||
public operator fun <T> Iterable<T>.plus(collection: Iterable<T>): List<T> {
|
||||
if (this is Collection) return this.plus(collection)
|
||||
val result = ArrayList<T>()
|
||||
result.addAll(this)
|
||||
result.addAll(collection)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then the given [element].
|
||||
*/
|
||||
@@ -1619,22 +1571,70 @@ public operator fun <T> Iterable<T>.plus(element: T): List<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [sequence].
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [elements] array.
|
||||
*/
|
||||
public operator fun <T> Collection<T>.plus(sequence: Sequence<T>): List<T> {
|
||||
val result = ArrayList<T>(this.size + 10)
|
||||
public operator fun <T> Collection<T>.plus(elements: Array<out T>): List<T> {
|
||||
val result = ArrayList<T>(this.size + elements.size)
|
||||
result.addAll(this)
|
||||
result.addAll(sequence)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [sequence].
|
||||
* 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(sequence: Sequence<T>): List<T> {
|
||||
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(sequence)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> {
|
||||
if (elements is Collection) {
|
||||
val result = ArrayList<T>(this.size + elements.size)
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
} else {
|
||||
val result = ArrayList<T>(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: Iterable<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] sequence.
|
||||
*/
|
||||
public operator fun <T> Collection<T>.plus(elements: Sequence<T>): List<T> {
|
||||
val result = ArrayList<T>(this.size + 10)
|
||||
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] 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
|
||||
}
|
||||
|
||||
|
||||
@@ -903,38 +903,6 @@ public fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> {
|
||||
return map { it ?: throw IllegalArgumentException("null element found in $this.") }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence except the elements contained in the given [array].
|
||||
* Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.minus(array: Array<out T>): Sequence<T> {
|
||||
if (array.isEmpty()) return this
|
||||
return object: Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
val other = array.toHashSet()
|
||||
return this@minus.filterNot { it in other }.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence except the elements contained in the given [collection].
|
||||
* Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.minus(collection: Iterable<T>): Sequence<T> {
|
||||
return object: Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
val other = collection.convertToSetForSetOperation()
|
||||
if (other.isEmpty())
|
||||
return this@minus.iterator()
|
||||
else
|
||||
return this@minus.filterNot { it in other }.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].
|
||||
*/
|
||||
@@ -948,14 +916,46 @@ public operator fun <T> Sequence<T>.minus(element: T): Sequence<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence].
|
||||
* Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] array.
|
||||
* Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.minus(elements: Array<out T>): Sequence<T> {
|
||||
if (elements.isEmpty()) return this
|
||||
return object: Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
val other = elements.toHashSet()
|
||||
return this@minus.filterNot { it in other }.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] collection.
|
||||
* Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.minus(elements: Iterable<T>): Sequence<T> {
|
||||
return object: Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
val other = elements.convertToSetForSetOperation()
|
||||
if (other.isEmpty())
|
||||
return this@minus.iterator()
|
||||
else
|
||||
return this@minus.filterNot { it in other }.iterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] sequence.
|
||||
* Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.minus(sequence: Sequence<T>): Sequence<T> {
|
||||
public operator fun <T> Sequence<T>.minus(elements: Sequence<T>): Sequence<T> {
|
||||
return object: Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
val other = sequence.toHashSet()
|
||||
val other = elements.toHashSet()
|
||||
if (other.isEmpty())
|
||||
return this@minus.iterator()
|
||||
else
|
||||
@@ -982,24 +982,6 @@ public inline fun <T> Sequence<T>.partition(predicate: (T) -> Boolean): Pair<Lis
|
||||
return Pair(first, second)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [array].
|
||||
* Note that the source sequence and the array being added are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.plus(array: Array<out T>): Sequence<T> {
|
||||
return this.plus(array.asList())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [collection].
|
||||
* Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.plus(collection: Iterable<T>): Sequence<T> {
|
||||
return sequenceOf(this, collection.asSequence()).flatten()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of the original sequence and then the given [element].
|
||||
*/
|
||||
@@ -1008,12 +990,30 @@ public operator fun <T> Sequence<T>.plus(element: T): Sequence<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [sequence].
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [elements] array.
|
||||
* Note that the source sequence and the array being added are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.plus(elements: Array<out T>): Sequence<T> {
|
||||
return this.plus(elements.asList())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [elements] collection.
|
||||
* Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.plus(elements: Iterable<T>): Sequence<T> {
|
||||
return sequenceOf(this, elements.asSequence()).flatten()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [elements] sequence.
|
||||
* Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from
|
||||
* the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
|
||||
*/
|
||||
public operator fun <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
|
||||
return sequenceOf(this, sequence).flatten()
|
||||
public operator fun <T> Sequence<T>.plus(elements: Sequence<T>): Sequence<T> {
|
||||
return sequenceOf(this, elements).flatten()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,19 +13,28 @@ import java.util.*
|
||||
import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [array].
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(array: Array<out T>): Set<T> {
|
||||
public operator fun <T> Set<T>.minus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size))
|
||||
var removed = false
|
||||
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] array.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(array)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [collection].
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] collection.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(collection: Iterable<T>): Set<T> {
|
||||
val other = collection.convertToSetForSetOperationWith(this)
|
||||
public operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> {
|
||||
val other = elements.convertToSetForSetOperationWith(this)
|
||||
if (other.isEmpty())
|
||||
return this.toSet()
|
||||
if (other is Set)
|
||||
@@ -36,40 +45,11 @@ public operator fun <T> Set<T>.minus(collection: Iterable<T>): Set<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] sequence.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size))
|
||||
var removed = false
|
||||
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [sequence].
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(sequence: Sequence<T>): Set<T> {
|
||||
public operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(sequence)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements both of the original set and the given [array].
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(array: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size + array.size))
|
||||
result.addAll(this)
|
||||
result.addAll(array)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements both of the original set and the given [collection].
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(collection: Iterable<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(collection.collectionSizeOrNull()?.let { this.size + it } ?: this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(collection)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -84,12 +64,32 @@ public operator fun <T> Set<T>.plus(element: T): Set<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements both of the original set and the given [sequence].
|
||||
* Returns a set containing all elements both of the original set and the given [elements] array.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(sequence: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size * 2))
|
||||
public operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size + elements.size))
|
||||
result.addAll(this)
|
||||
result.addAll(sequence)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements both of the original set and the given [elements] collection.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(elements.collectionSizeOrNull()?.let { this.size + it } ?: this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements both of the original set and the given [elements] sequence.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user