org.pkl.thirdparty.kotlin.collections.SetsJVM.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pkl-tools Show documentation
Show all versions of pkl-tools Show documentation
Fat Jar containing pkl-cli, pkl-codegen-java, pkl-codegen-kotlin, pkl-config-java, pkl-core, pkl-doc, and their shaded third-party dependencies.
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:org.pkl.thirdparty.kotlin.jvm.JvmMultifileClass
@file:org.pkl.thirdparty.kotlin.jvm.JvmName("SetsKt")
package org.pkl.thirdparty.kotlin.collections
import org.pkl.thirdparty.kotlin.collections.builders.SetBuilder
/**
* Returns an immutable set containing only the specified object [element].
* The returned set is serializable.
*/
public fun setOf(element: T): Set = java.util.Collections.singleton(element)
@PublishedApi
@SinceKotlin("1.3")
@org.pkl.thirdparty.kotlin.internal.InlineOnly
internal actual inline fun buildSetInternal(builderAction: MutableSet.() -> Unit): Set {
return build(createSetBuilder().apply(builderAction))
}
@PublishedApi
@SinceKotlin("1.3")
@org.pkl.thirdparty.kotlin.internal.InlineOnly
internal actual inline fun buildSetInternal(capacity: Int, builderAction: MutableSet.() -> Unit): Set {
return build(createSetBuilder(capacity).apply(builderAction))
}
@PublishedApi
@SinceKotlin("1.3")
internal fun createSetBuilder(): MutableSet {
return SetBuilder()
}
@PublishedApi
@SinceKotlin("1.3")
internal fun createSetBuilder(capacity: Int): MutableSet {
return SetBuilder(capacity)
}
@PublishedApi
@SinceKotlin("1.3")
internal fun build(builder: MutableSet): Set {
return (builder as SetBuilder).build()
}
/**
* Returns a new [java.util.SortedSet] with the given elements.
*/
public fun sortedSetOf(vararg elements: T): java.util.TreeSet = elements.toCollection(java.util.TreeSet())
/**
* Returns a new [java.util.SortedSet] with the given [comparator] and elements.
*/
public fun sortedSetOf(comparator: Comparator, vararg elements: T): java.util.TreeSet = elements.toCollection(java.util.TreeSet(comparator))
© 2015 - 2024 Weber Informatics LLC | Privacy Policy