공부
[kotlin] MutableMap & MutableList (capacity: Int)
승가비
2023. 4. 26. 22:56
728x90
fun <K, V> mutableMapWithCapacity(capacity: Int): MutableMap<K, V> =
LinkedHashMap(capacity)
fun <T> mutableListWithCapacity(capacity: Int): MutableList<T> =
ArrayList(capacity)
https://stackoverflow.com/questions/61698098/kotlin-mutablelist-initial-capacity
Kotlin MutableList initial capacity
I'm creating a list of values, in a context where it so happens that, though the values are being added one at a time, the eventual number is known in advance. This is in a function that will be ca...
stackoverflow.com
728x90