Is there built-in data structure in clojure supporting both duplicated elements and O(1) removing? -
recently, need implement special set in clojure may have duplicated elements (i.e. multiset), like
#{1 2 3 4 1 2}
what's more, removing arbitrary element equal assigned value in o(1) time needed well. example, when type
(my-remove #{1 1 2 2 3 4} 2)
it should return #{1 1 2 3 4}
without loop through whole set(or vector).
my question is, there built-in data structure in clojure satisfying these 2 properties. if not, there proper alternative solution implement this? thanks!
a map of values "count" ? (removing value decreasing counter ?)
Comments
Post a Comment