For example, Scala has the official Collections Performance Characteristics page that shows the time complexity of methods like apply()(get in Java), insert(), and append() in collections like List, Array, and ArrayBuffer.
However, I cannot find such kind of information in Kotlin.
The Kotlin stdlib API page also does not have such information. Even worse, I don't get the information about the underlying implementation of List (created by listOf() or so), for example unless I dig into the source code.
So does List in Kotlin take O(n) time accessing an element, and take O(1) time appending an element?
Where can I find this information?
Kotlin stdlib does not contain its own collections, on JVM listOf is just a binding to Java's Collections.emptyList(), Collections.singletonList(), and ArrayList. ArrayList has O(1) positional access complexity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With