Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associative methods don't work on transient ordered maps #69

Open
NoahTheDuke opened this issue Dec 20, 2021 · 1 comment
Open

Associative methods don't work on transient ordered maps #69

NoahTheDuke opened this issue Dec 20, 2021 · 1 comment

Comments

@NoahTheDuke
Copy link
Contributor

NoahTheDuke commented Dec 20, 2021

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant