As for the implements right now, all the toSet
, setOf
and mutableSetOf
are all implemented with LinkedHashSet
.
Kotlin provides the function of linkedSetOf
to explicitly create a LinkedHashSet
.
/**
* Returns a new [LinkedHashSet] with the given elements.
* Elements of the set are iterated in the order they were specified.
*/
public fun <T> linkedSetOf(vararg elements: T): LinkedHashSet<T> = elements.toCollection(LinkedHashSet(mapCapacity(elements.size)))