Closed jmesserly closed 6 years ago
Removed Library-Collections label. Added Library-Collection label.
We probably want a different sorted map too, with more predictable performance. If that happens, we could add SortedMap as superclass for those.
Removed Type-Defect label. Added Type-Enhancement label.
+1, nice idea. out of curiosity, what data structure were you thinking? classic RB-tree?
Never answered this. It'll most likely be an AVL tree - it's simple to implement and usually at least as efficient as a Red/Black tree.
updated subject based on https://github.com/dart-lang/sdk/issues/5611#issuecomment-108333802 ... since renaming it won't happen at this point :)
I feel that introducing OrderedMap
, SortedMap
, OrderedSet
, and SortedSet
would benefit the language since they allow developers to be more expressive with their code by using abstract data types as opposed to using data structures like SplayTreeMap
to express the usage of a Sorted Map, or even worse, using Map
as a catch-all.
Also, this would allow Map
and Set
to use HashMap
and Hashset
data structures, respectively, by default instead of their current default LinkedHashMap
and LinkedHashSet
implementations which are less efficient and unnecessarily ordered (since a Map is an unordered abstract data type).
It would be really nice to have "SortedSet" and "SortedMap". SplayTreeMap works great, but the name contains implementation details. It we decide at some time down the road that we want to implement it with some other kind of binary search tree, it won't be very good.
Also as a user, I find myself frequently adding comments like "using SplayTreeMap to keep this sorted so we iterate in a stable order". Whereas "SortedMap" would be a self documenting name.