fun <T> linkedSetOf(): LinkedHashSet<T>
Returns an empty new LinkedHashSet.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val set: LinkedHashSet<Int> = linkedSetOf<Int>()
set.add(1)
set.add(3)
set.add(2)
println(set) // [1, 3, 2]
//sampleEnd
}
fun <T> linkedSetOf(vararg elements: T): LinkedHashSet<T>
Returns a new LinkedHashSet with the given elements. Elements of the set are iterated in the order they were specified.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val set: LinkedHashSet<Int> = linkedSetOf(1, 3, 2)
println(set) // [1, 3, 2]
set.remove(3)
set += listOf(5, 4)
println(set) // [1, 2, 5, 4]
//sampleEnd
}
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/linked-set-of.html