A card that stores its keys in the order in which they were added to

Is there a data structure in Clojure that can meet these requirements:

  • represent key-value pairs, i.e. constitute a map;
  • getoperation uses less O(n);
  • keep the keys in the order in which they are added.
+3
source share
2 answers

I also needed this. I usually set + card to seq (which contains the order of the keys). You can go for all the inconstancy and use LinkedHashMap, but I think God kills a kitten if you do.

Can Chris Houser implement a finger tree sign an account?

+3

user=> (sorted-map-by (fn [_ _] -1) :a 1 :b 2 :c 3 :d 4)
{:d 4, :c 3, :b 2, :a 1}

, -1. . a >

. . .

0

Source: https://habr.com/ru/post/1775332/


All Articles