Open jeff303 opened 3 years ago
I'm not sure how to handle transients here (i.e. submap!
).
PersistentTreeMap
, so the problem where the previous navigator didn't preserve order doesn't apply thereTransientArrayMap
and TransientHashMap
, the order already appears preserved by select-keys
(see REPL session below)# for TransientHashMap
(select-keys (transient {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9 :j 10 :k 11 :l 12 :m 13}) [:a :c :e :g :i :k :m])
{:a 1, :c 3, :e 5, :g 7, :i 9, :k 11, :m 13}
# for TransientArrayMap
(select-keys (transient {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7}) [:g :f :e :d :c :b :a])
{:g 7, :f 6, :e 5, :d 4, :c 3, :b 2, :a 1}
Couple comments:
Object
which does select-keys
and only having a special case for PersistentTreeMap
.Also, transients aren't supported on PersistentTreeMap, so submap!
doesn't need any changes.
Added the test for the actual comparator (couldn't quickly figure out if/how to make that work in cljs).
Also, transients aren't supported on PersistentTreeMap, so
submap!
doesn't need any changes
OK, thanks for the confirmation. The starter comment on #235 is what got me looking at it.
TODO: figure out how to handle transients (i.e. submap!)
Adding new SubMap protocol to handle the different implementations of key selection (including one that maintains order to be used for sorted-map)
Adding test to ensure order preserved for a large map