Boris Egorov
01/23/2023, 5:07 PMMutableMap
(and it can be created with mutableMapOf
). But it is a trouble to find characteristics of this data structure (for example, insertion algorithmic complexity). Googling "mutable map kotlin" brings you to jvm docs, where there the only perf-related phrase is "supports efficiently retrieving the value corresponding to each key." Maybe it is enough to get job done, maybe not. "MutableMap kotlin performance" brings some blog post which mentions that MutableMap can be seen as hash table. But no official docs still.
• I want to use String
and I assume it would be actively sliced/taken substring of. I remember that `String`s are immutable, so probably it would take constant time to do this. But I totally fail to find this in docs.count
• Rust SliceIndex: This operation is _O_(1)
. Not quiet ideal place to describe this — there are functions for slicing above — but still on the same page.ephemient
01/23/2023, 5:10 PMMutableMap
is just an interface, it can have any number of implementations with different performance characteristicsmutableMapOf()
is LinkedHashMap, although that is considered an implementation detailString.substring
have changed behavior over different Java releasesLandry Norris
01/23/2023, 5:14 PMBoris Egorov
01/23/2023, 5:16 PMephemient
01/23/2023, 5:18 PM.get()
and .iterator().next()
are O(1). there are a few types that break these assumptions though, such as LinkedList
and CoroutineContext
Sam
01/23/2023, 5:36 PMmapOf
, listOf
, etc. are for cases when you don't really care about the complexity and just want it to be something reasonably sensible
• when you do care more about the specific implementation, you can instead use one of the specific constructors for HashMap
, ArrayList
, etc.ephemient
01/23/2023, 5:43 PMSam
01/23/2023, 5:43 PMephemient
01/23/2023, 5:44 PMArrayList
, so you should already have expectations for itLandry Norris
01/23/2023, 5:45 PM