StdLib: Rename method parameters (Collections)

This commit is contained in:
Ilya Gorbunov
2015-11-16 23:20:16 +03:00
parent c3190bbae3
commit a3cd86d2cd
5 changed files with 99 additions and 99 deletions
+14 -14
View File
@@ -3,53 +3,53 @@ package kotlin
import java.util.* import java.util.*
@library @library
public fun <T> arrayOf(vararg value : T): Array<T> = noImpl public fun <T> arrayOf(vararg elements: T): Array<T> = noImpl
// "constructors" for primitive types array // "constructors" for primitive types array
@library @library
public fun doubleArrayOf(vararg content : Double): DoubleArray = noImpl public fun doubleArrayOf(vararg elements: Double): DoubleArray = noImpl
@library @library
public fun floatArrayOf(vararg content : Float): FloatArray = noImpl public fun floatArrayOf(vararg elements: Float): FloatArray = noImpl
@library @library
public fun longArrayOf(vararg content : Long): LongArray = noImpl public fun longArrayOf(vararg elements: Long): LongArray = noImpl
@library @library
public fun intArrayOf(vararg content : Int): IntArray = noImpl public fun intArrayOf(vararg elements: Int): IntArray = noImpl
@library @library
public fun charArrayOf(vararg content : Char): CharArray = noImpl public fun charArrayOf(vararg elements: Char): CharArray = noImpl
@library @library
public fun shortArrayOf(vararg content : Short): ShortArray = noImpl public fun shortArrayOf(vararg elements: Short): ShortArray = noImpl
@library @library
public fun byteArrayOf(vararg content : Byte): ByteArray = noImpl public fun byteArrayOf(vararg elements: Byte): ByteArray = noImpl
@library @library
public fun booleanArrayOf(vararg content : Boolean): BooleanArray = noImpl public fun booleanArrayOf(vararg elements: Boolean): BooleanArray = noImpl
@library("copyToArray") @library("copyToArray")
public fun <reified T> Collection<T>.toTypedArray(): Array<T> = noImpl public fun <reified T> Collection<T>.toTypedArray(): Array<T> = noImpl
/** /**
* Returns an immutable list containing only the specified object [value]. * Returns an immutable list containing only the specified object [element].
*/ */
public fun listOf<T>(value: T): List<T> = arrayListOf(value) public fun listOf<T>(element: T): List<T> = arrayListOf(element)
/** /**
* Returns an immutable set containing only the specified object [value]. * Returns an immutable set containing only the specified object [element].
*/ */
public fun setOf<T>(value: T): Set<T> = hashSetOf(value) public fun setOf<T>(element: T): Set<T> = hashSetOf(element)
/** /**
* Returns an immutable map, mapping only the specified key to the * Returns an immutable map, mapping only the specified key to the
* specified value. * specified value.
*/ */
public fun mapOf<K, V>(keyValuePair: Pair<K, V>): Map<K, V> = hashMapOf(keyValuePair) public fun mapOf<K, V>(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)
/** /**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]. * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
@@ -11,48 +11,48 @@ import kotlin.jvm.internal.Intrinsic
/** /**
* Returns an array containing the specified elements. * Returns an array containing the specified elements.
*/ */
@Intrinsic("kotlin.arrays.array") public fun <reified T> arrayOf(vararg t : T) : Array<T> = t as Array<T> @Intrinsic("kotlin.arrays.array") public fun <reified T> arrayOf(vararg elements: T) : Array<T> = elements as Array<T>
// "constructors" for primitive types array // "constructors" for primitive types array
/** /**
* Returns an array containing the specified [Double] numbers. * Returns an array containing the specified [Double] numbers.
*/ */
@Intrinsic("kotlin.arrays.array") public fun doubleArrayOf(vararg content : Double) : DoubleArray = content @Intrinsic("kotlin.arrays.array") public fun doubleArrayOf(vararg elements: Double) : DoubleArray = elements
/** /**
* Returns an array containing the specified [Float] numbers. * Returns an array containing the specified [Float] numbers.
*/ */
@Intrinsic("kotlin.arrays.array") public fun floatArrayOf(vararg content : Float) : FloatArray = content @Intrinsic("kotlin.arrays.array") public fun floatArrayOf(vararg elements: Float) : FloatArray = elements
/** /**
* Returns an array containing the specified [Long] numbers. * Returns an array containing the specified [Long] numbers.
*/ */
@Intrinsic("kotlin.arrays.array") public fun longArrayOf(vararg content : Long) : LongArray = content @Intrinsic("kotlin.arrays.array") public fun longArrayOf(vararg elements: Long) : LongArray = elements
/** /**
* Returns an array containing the specified [Int] numbers. * Returns an array containing the specified [Int] numbers.
*/ */
@Intrinsic("kotlin.arrays.array") public fun intArrayOf(vararg content : Int) : IntArray = content @Intrinsic("kotlin.arrays.array") public fun intArrayOf(vararg elements: Int) : IntArray = elements
/** /**
* Returns an array containing the specified characters. * Returns an array containing the specified characters.
*/ */
@Intrinsic("kotlin.arrays.array") public fun charArrayOf(vararg content : Char) : CharArray = content @Intrinsic("kotlin.arrays.array") public fun charArrayOf(vararg elements: Char) : CharArray = elements
/** /**
* Returns an array containing the specified [Short] numbers. * Returns an array containing the specified [Short] numbers.
*/ */
@Intrinsic("kotlin.arrays.array") public fun shortArrayOf(vararg content : Short) : ShortArray = content @Intrinsic("kotlin.arrays.array") public fun shortArrayOf(vararg elements: Short) : ShortArray = elements
/** /**
* Returns an array containing the specified [Byte] numbers. * Returns an array containing the specified [Byte] numbers.
*/ */
@Intrinsic("kotlin.arrays.array") public fun byteArrayOf(vararg content : Byte) : ByteArray = content @Intrinsic("kotlin.arrays.array") public fun byteArrayOf(vararg elements: Byte) : ByteArray = elements
/** /**
* Returns an array containing the specified boolean values. * Returns an array containing the specified boolean values.
*/ */
@Intrinsic("kotlin.arrays.array") public fun booleanArrayOf(vararg content : Boolean) : BooleanArray = content @Intrinsic("kotlin.arrays.array") public fun booleanArrayOf(vararg elements: Boolean) : BooleanArray = elements
/** /**
* Converts the contents of this byte array to a string using the specified [charset]. * Converts the contents of this byte array to a string using the specified [charset].
@@ -22,12 +22,12 @@ internal object EmptyList : List<Nothing>, Serializable {
override val size: Int get() = 0 override val size: Int get() = 0
override fun isEmpty(): Boolean = true override fun isEmpty(): Boolean = true
override fun contains(o: Nothing): Boolean = false override fun contains(element: Nothing): Boolean = false
override fun containsAll(c: Collection<Nothing>): Boolean = c.isEmpty() override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()
override fun get(index: Int): Nothing = throw IndexOutOfBoundsException("Index $index is out of bound of empty list.") override fun get(index: Int): Nothing = throw IndexOutOfBoundsException("Index $index is out of bound of empty list.")
override fun indexOf(o: Nothing): Int = -1 override fun indexOf(element: Nothing): Int = -1
override fun lastIndexOf(o: Nothing): Int = -1 override fun lastIndexOf(element: Nothing): Int = -1
override fun iterator(): Iterator<Nothing> = EmptyIterator override fun iterator(): Iterator<Nothing> = EmptyIterator
override fun listIterator(): ListIterator<Nothing> = EmptyIterator override fun listIterator(): ListIterator<Nothing> = EmptyIterator
@@ -49,8 +49,8 @@ internal fun <T> Array<out T>.asCollection(): Collection<T> = ArrayAsCollection(
private class ArrayAsCollection<T>(val values: Array<out T>): Collection<T> { private class ArrayAsCollection<T>(val values: Array<out T>): Collection<T> {
override val size: Int get() = values.size override val size: Int get() = values.size
override fun isEmpty(): Boolean = values.isEmpty() override fun isEmpty(): Boolean = values.isEmpty()
override fun contains(o: T): Boolean = values.contains(o) override fun contains(element: T): Boolean = values.contains(element)
override fun containsAll(c: Collection<T>): Boolean = c.all { contains(it) } override fun containsAll(elements: Collection<T>): Boolean = elements.all { contains(it) }
override fun iterator(): Iterator<T> = values.iterator() override fun iterator(): Iterator<T> = values.iterator()
// override hidden toArray implementation to prevent copying of values array // override hidden toArray implementation to prevent copying of values array
public fun toArray(): Array<out Any?> = values.varargToArrayOfAny() public fun toArray(): Array<out Any?> = values.varargToArrayOfAny()
@@ -60,32 +60,32 @@ private class ArrayAsCollection<T>(val values: Array<out T>): Collection<T> {
public fun <T> emptyList(): List<T> = EmptyList public fun <T> emptyList(): List<T> = EmptyList
/** Returns a new read-only list of given elements. The returned list is serializable (JVM). */ /** Returns a new read-only list of given elements. The returned list is serializable (JVM). */
public fun <T> listOf(vararg values: T): List<T> = if (values.size > 0) values.asList() else emptyList() public fun <T> listOf(vararg elements: T): List<T> = if (elements.size > 0) elements.asList() else emptyList()
/** Returns an empty read-only list. The returned list is serializable (JVM). */ /** Returns an empty read-only list. The returned list is serializable (JVM). */
public fun <T> listOf(): List<T> = emptyList() public fun <T> listOf(): List<T> = emptyList()
/** /**
* Returns an immutable list containing only the specified object [value]. * Returns an immutable list containing only the specified object [element].
* The returned list is serializable. * The returned list is serializable.
*/ */
@JvmVersion @JvmVersion
public fun <T> listOf(value: T): List<T> = Collections.singletonList(value) public fun <T> listOf(element: T): List<T> = Collections.singletonList(element)
/** Returns a new [LinkedList] with the given elements. */ /** Returns a new [LinkedList] with the given elements. */
@JvmVersion @JvmVersion
public fun <T> linkedListOf(vararg values: T): LinkedList<T> public fun <T> linkedListOf(vararg elements: T): LinkedList<T>
= if (values.size == 0) LinkedList() else LinkedList(ArrayAsCollection(values)) = if (elements.size == 0) LinkedList() else LinkedList(ArrayAsCollection(elements))
/** Returns a new [ArrayList] with the given elements. */ /** Returns a new [ArrayList] with the given elements. */
public fun <T> arrayListOf(vararg values: T): ArrayList<T> public fun <T> arrayListOf(vararg elements: T): ArrayList<T>
= if (values.size == 0) ArrayList() else ArrayList(ArrayAsCollection(values)) = if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements))
/** Returns a new read-only list either of single given element, if it is not null, or empty list it the element is null. The returned list is serializable (JVM). */ /** Returns a new read-only list either of single given element, if it is not null, or empty list it the element is null. The returned list is serializable (JVM). */
public fun <T : Any> listOfNotNull(value: T?): List<T> = if (value != null) listOf(value) else emptyList() public fun <T : Any> listOfNotNull(element: T?): List<T> = if (element != null) listOf(element) else emptyList()
/** Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM). */ /** Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM). */
public fun <T : Any> listOfNotNull(vararg values: T?): List<T> = values.filterNotNull() public fun <T : Any> listOfNotNull(vararg elements: T?): List<T> = elements.filterNotNull()
/** /**
* Returns an [IntRange] of the valid indices for this collection. * Returns an [IntRange] of the valid indices for this collection.
@@ -11,7 +11,7 @@ import java.util.*
* Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`. * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun Collection<*>.containsAllRaw(collection: Collection<Any?>): Boolean = (this as Collection<Any?>).containsAll(collection) public inline fun Collection<*>.containsAllRaw(elements: Collection<Any?>): Boolean = (this as Collection<Any?>).containsAll(elements)
/** /**
* Removes a single instance of the specified element from this * Removes a single instance of the specified element from this
@@ -32,7 +32,7 @@ public inline fun <E> MutableCollection<E>.removeRaw(element: Any?): Boolean = (
* @return `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified. * @return `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified.
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun <E> MutableCollection<E>.removeAllRaw(collection: Collection<Any?>): Boolean = (this as MutableCollection<Any?>).removeAll(collection) public inline fun <E> MutableCollection<E>.removeAllRaw(elements: Collection<Any?>): Boolean = (this as MutableCollection<Any?>).removeAll(elements)
/** /**
* Retains only the elements in this collection that are contained in the specified collection. * Retains only the elements in this collection that are contained in the specified collection.
@@ -42,7 +42,7 @@ public inline fun <E> MutableCollection<E>.removeAllRaw(collection: Collection<A
* @return `true` if any element was removed from the collection, `false` if the collection was not modified. * @return `true` if any element was removed from the collection, `false` if the collection was not modified.
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
public inline fun <E> MutableCollection<E>.retainAllRaw(collection: Collection<Any?>): Boolean = (this as MutableCollection<Any?>).retainAll(collection) public inline fun <E> MutableCollection<E>.retainAllRaw(elements: Collection<Any?>): Boolean = (this as MutableCollection<Any?>).retainAll(elements)
@@ -123,24 +123,24 @@ public operator fun <T> MutableCollection<in T>.plusAssign(element: T) {
} }
/** /**
* Adds all elements of the given [collection] to this mutable collection. * Adds all elements of the given [elements] collection to this mutable collection.
*/ */
public operator fun <T> MutableCollection<in T>.plusAssign(collection: Iterable<T>) { public operator fun <T> MutableCollection<in T>.plusAssign(elements: Iterable<T>) {
this.addAll(collection) this.addAll(elements)
} }
/** /**
* Adds all elements of the given [array] to this mutable collection. * Adds all elements of the given [elements] array to this mutable collection.
*/ */
public operator fun <T> MutableCollection<in T>.plusAssign(array: Array<T>) { public operator fun <T> MutableCollection<in T>.plusAssign(elements: Array<T>) {
this.addAll(array) this.addAll(elements)
} }
/** /**
* Adds all elements of the given [sequence] to this mutable collection. * Adds all elements of the given [elements] sequence to this mutable collection.
*/ */
public operator fun <T> MutableCollection<in T>.plusAssign(sequence: Sequence<T>) { public operator fun <T> MutableCollection<in T>.plusAssign(elements: Sequence<T>) {
this.addAll(sequence) this.addAll(elements)
} }
/** /**
@@ -151,99 +151,99 @@ public operator fun <T> MutableCollection<in T>.minusAssign(element: T) {
} }
/** /**
* Removes all elements contained in the given [collection] from this mutable collection. * Removes all elements contained in the given [elements] collection from this mutable collection.
*/ */
public operator fun <T> MutableCollection<in T>.minusAssign(collection: Iterable<T>) { public operator fun <T> MutableCollection<in T>.minusAssign(elements: Iterable<T>) {
this.removeAll(collection) this.removeAll(elements)
} }
/** /**
* Removes all elements contained in the given [array] from this mutable collection. * Removes all elements contained in the given [elements] array from this mutable collection.
*/ */
public operator fun <T> MutableCollection<in T>.minusAssign(array: Array<T>) { public operator fun <T> MutableCollection<in T>.minusAssign(elements: Array<T>) {
this.removeAll(array) this.removeAll(elements)
} }
/** /**
* Removes all elements contained in the given [sequence] from this mutable collection. * Removes all elements contained in the given [elements] sequence from this mutable collection.
*/ */
public operator fun <T> MutableCollection<in T>.minusAssign(sequence: Sequence<T>) { public operator fun <T> MutableCollection<in T>.minusAssign(elements: Sequence<T>) {
this.removeAll(sequence) this.removeAll(elements)
} }
/** /**
* Adds all elements of the given [iterable] to this [MutableCollection]. * Adds all elements of the given [elements] collection to this [MutableCollection].
*/ */
public fun <T> MutableCollection<in T>.addAll(iterable: Iterable<T>) { public fun <T> MutableCollection<in T>.addAll(elements: Iterable<T>) {
when (iterable) { when (elements) {
is Collection -> addAll(iterable) is Collection -> addAll(elements)
else -> for (item in iterable) add(item) else -> for (item in elements) add(item)
} }
} }
/** /**
* Adds all elements of the given [sequence] to this [MutableCollection]. * Adds all elements of the given [elements] sequence to this [MutableCollection].
*/ */
public fun <T> MutableCollection<in T>.addAll(sequence: Sequence<T>) { public fun <T> MutableCollection<in T>.addAll(elements: Sequence<T>) {
for (item in sequence) add(item) for (item in elements) add(item)
} }
/** /**
* Adds all elements of the given [array] to this [MutableCollection]. * Adds all elements of the given [elements] array to this [MutableCollection].
*/ */
public fun <T> MutableCollection<in T>.addAll(array: Array<out T>) { public fun <T> MutableCollection<in T>.addAll(elements: Array<out T>) {
addAll(array.asList()) addAll(elements.asList())
} }
/** /**
* Removes all elements from this [MutableCollection] that are also contained in the given [iterable]. * Removes all elements from this [MutableCollection] that are also contained in the given [elements] collection.
*/ */
public fun <T> MutableCollection<in T>.removeAll(iterable: Iterable<T>) { public fun <T> MutableCollection<in T>.removeAll(elements: Iterable<T>) {
removeAll(iterable.convertToSetForSetOperationWith(this)) removeAll(elements.convertToSetForSetOperationWith(this))
} }
/** /**
* Removes all elements from this [MutableCollection] that are also contained in the given [sequence]. * Removes all elements from this [MutableCollection] that are also contained in the given [elements] sequence.
*/ */
public fun <T> MutableCollection<in T>.removeAll(sequence: Sequence<T>) { public fun <T> MutableCollection<in T>.removeAll(elements: Sequence<T>) {
val set = sequence.toHashSet() val set = elements.toHashSet()
if (set.isNotEmpty()) if (set.isNotEmpty())
removeAll(set) removeAll(set)
} }
/** /**
* Removes all elements from this [MutableCollection] that are also contained in the given [array]. * Removes all elements from this [MutableCollection] that are also contained in the given [elements] array.
*/ */
public fun <T> MutableCollection<in T>.removeAll(array: Array<out T>) { public fun <T> MutableCollection<in T>.removeAll(elements: Array<out T>) {
if (array.isNotEmpty()) if (elements.isNotEmpty())
removeAll(array.toHashSet()) removeAll(elements.toHashSet())
// else // else
// removeAll(emptyList()) // removeAll(emptyList())
} }
/** /**
* Retains only elements of this [MutableCollection] that are contained in the given [iterable]. * Retains only elements of this [MutableCollection] that are contained in the given [elements] collection.
*/ */
public fun <T> MutableCollection<in T>.retainAll(iterable: Iterable<T>) { public fun <T> MutableCollection<in T>.retainAll(elements: Iterable<T>) {
retainAll(iterable.convertToSetForSetOperationWith(this)) retainAll(elements.convertToSetForSetOperationWith(this))
} }
/** /**
* Retains only elements of this [MutableCollection] that are contained in the given [array]. * Retains only elements of this [MutableCollection] that are contained in the given [elements] array.
*/ */
public fun <T> MutableCollection<in T>.retainAll(array: Array<out T>) { public fun <T> MutableCollection<in T>.retainAll(elements: Array<out T>) {
if (array.isNotEmpty()) if (elements.isNotEmpty())
retainAll(array.toHashSet()) retainAll(elements.toHashSet())
else else
clear() clear()
// retainAll(emptyList()) // retainAll(emptyList())
} }
/** /**
* Retains only elements of this [MutableCollection] that are contained in the given [sequence]. * Retains only elements of this [MutableCollection] that are contained in the given [elements] sequence.
*/ */
public fun <T> MutableCollection<in T>.retainAll(sequence: Sequence<T>) { public fun <T> MutableCollection<in T>.retainAll(elements: Sequence<T>) {
val set = sequence.toHashSet() val set = elements.toHashSet()
if (set.isNotEmpty()) if (set.isNotEmpty())
retainAll(set) retainAll(set)
else else
@@ -14,8 +14,8 @@ internal object EmptySet : Set<Nothing>, Serializable {
override val size: Int get() = 0 override val size: Int get() = 0
override fun isEmpty(): Boolean = true override fun isEmpty(): Boolean = true
override fun contains(o: Nothing): Boolean = false override fun contains(element: Nothing): Boolean = false
override fun containsAll(c: Collection<Nothing>): Boolean = c.isEmpty() override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()
override fun iterator(): Iterator<Nothing> = EmptyIterator override fun iterator(): Iterator<Nothing> = EmptyIterator
@@ -26,37 +26,37 @@ internal object EmptySet : Set<Nothing>, Serializable {
/** Returns an empty read-only set. The returned set is serializable (JVM). */ /** Returns an empty read-only set. The returned set is serializable (JVM). */
public fun <T> emptySet(): Set<T> = EmptySet public fun <T> emptySet(): Set<T> = EmptySet
/** Returns a new read-only ordered set with the given elements. The returned set is serializable (JVM). */ /** Returns a new read-only ordered set with the given elements. The returned set is serializable (JVM). */
public fun <T> setOf(vararg values: T): Set<T> = if (values.size > 0) values.toSet() else emptySet() public fun <T> setOf(vararg elements: T): Set<T> = if (elements.size > 0) elements.toSet() else emptySet()
/** Returns an empty read-only set. The returned set is serializable (JVM). */ /** Returns an empty read-only set. The returned set is serializable (JVM). */
public fun <T> setOf(): Set<T> = emptySet() public fun <T> setOf(): Set<T> = emptySet()
/** Returns a new [HashSet] with the given elements. */ /** Returns a new [HashSet] with the given elements. */
public fun <T> hashSetOf(vararg values: T): HashSet<T> = values.toCollection(HashSet(mapCapacity(values.size))) public fun <T> hashSetOf(vararg elements: T): HashSet<T> = elements.toCollection(HashSet(mapCapacity(elements.size)))
/** Returns a new [LinkedHashSet] with the given elements. */ /** Returns a new [LinkedHashSet] with the given elements. */
public fun <T> linkedSetOf(vararg values: T): LinkedHashSet<T> = values.toCollection(LinkedHashSet(mapCapacity(values.size))) public fun <T> linkedSetOf(vararg elements: T): LinkedHashSet<T> = elements.toCollection(LinkedHashSet(mapCapacity(elements.size)))
/** Returns this Set if it's not `null` and the empty set otherwise. */ /** Returns this Set if it's not `null` and the empty set otherwise. */
public fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet() public fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet()
/** /**
* Returns an immutable set containing only the specified object [value]. * Returns an immutable set containing only the specified object [element].
* The returned set is serializable. * The returned set is serializable.
*/ */
@JvmVersion @JvmVersion
public fun <T> setOf(value: T): Set<T> = Collections.singleton(value) public fun <T> setOf(element: T): Set<T> = Collections.singleton(element)
/** /**
* Returns a new [SortedSet] with the given elements. * Returns a new [SortedSet] with the given elements.
*/ */
@JvmVersion @JvmVersion
public fun <T> sortedSetOf(vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>()) public fun <T> sortedSetOf(vararg elements: T): TreeSet<T> = elements.toCollection(TreeSet<T>())
/** /**
* Returns a new [SortedSet] with the given [comparator] and elements. * Returns a new [SortedSet] with the given [comparator] and elements.
*/ */
@JvmVersion @JvmVersion
public fun <T> sortedSetOf(comparator: Comparator<in T>, vararg values: T): TreeSet<T> = values.toCollection(TreeSet<T>(comparator)) public fun <T> sortedSetOf(comparator: Comparator<in T>, vararg elements: T): TreeSet<T> = elements.toCollection(TreeSet<T>(comparator))