generated._Sets.kt Maven / Gradle / Ivy
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("SetsKt")
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
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].
*/
public operator fun Set.minus(array: Array): Set {
val result = LinkedHashSet(this)
result.removeAll(array)
return result
}
/**
* Returns a set containing all elements of the original set except the elements contained in the given [collection].
*/
public operator fun Set.minus(collection: Iterable): Set {
val other = collection.convertToSetForSetOperationWith(this)
if (other.isEmpty())
return this.toSet()
if (other is Set)
return this.filterNotTo(LinkedHashSet()) { it in other }
val result = LinkedHashSet(this)
result.removeAll(other)
return result
}
/**
* Returns a set containing all elements of the original set except the given [element].
*/
public operator fun Set.minus(element: T): Set {
val result = LinkedHashSet(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 Set.minus(sequence: Sequence): Set {
val result = LinkedHashSet(this)
result.removeAll(sequence)
return result
}
/**
* Returns a set containing all elements both of the original set and the given [array].
*/
public operator fun Set.plus(array: Array): Set {
val result = LinkedHashSet(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 Set.plus(collection: Iterable): Set {
val result = LinkedHashSet(mapCapacity(collection.collectionSizeOrNull()?.let { this.size() + it } ?: this.size() * 2))
result.addAll(this)
result.addAll(collection)
return result
}
/**
* Returns a set containing all elements of the original set and then the given [element].
*/
public operator fun Set.plus(element: T): Set {
val result = LinkedHashSet(mapCapacity(size() + 1))
result.addAll(this)
result.add(element)
return result
}
/**
* Returns a set containing all elements both of the original set and the given [sequence].
*/
public operator fun Set.plus(sequence: Sequence): Set {
val result = LinkedHashSet(mapCapacity(this.size() * 2))
result.addAll(this)
result.addAll(sequence)
return result
}