ordered icon indicating copy to clipboard operation
ordered copied to clipboard

Associative methods don't work on transient ordered maps

Open NoahTheDuke opened this issue 3 years ago • 1 comments
trafficstars

OrderedMap doesn't implement ITransientAssociative2 (which the clojure.core transient maps do), so using contains? or find on a transient OrderedMap throws a contains? not supported on type: flatland.ordered.map.TransientOrderedMap error.

NoahTheDuke avatar Dec 20 '21 17:12 NoahTheDuke

Looking at clojure.core, the simplest solution is to just implement ITransientAssociative2 directly, mirroring the existing Java implementation in ATransientMap:

  clojure.lang.ITransientAssociative2
  (containsKey [this k]
    (not= (.valAt this k ::not-found) ::not-found))
  (entryAt [this k]
    (let [v (.valAt this k ::not-found)]
      (when (not= v ::not-found)
        (MapEntry. k v))))

If #68 is acceptable, ::not-found could be switched to not-found as well.

NoahTheDuke avatar Dec 20 '21 19:12 NoahTheDuke