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

Implement IdentityHashMap for the JS target #195

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

lppedd
Copy link
Contributor

@lppedd lppedd commented Aug 25, 2024

Finally managed to implement a proper identity map for K/JS, using the ES2015 Map as backing store.

WASM and Native are more complex, and less used, so they'll have to wait longer.
And I'm not even sure it's possible in WASM.

The next step (another PR) is moving CopyOnWriteArrayList, IdentityHashMap and WeakHashMap to be internal, to avoid consumers using them and having to deal with unexpected results.

prev = imap.put(a, "two")
assertNull(prev)

val b = B("one")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would also be interesting to see if we can insert two elements that equals but do not have the same identity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last commit addresses both of the remaining comments.


@Test
fun containsValue() {
val imap = IdentityHashMap<String, A>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to write a test using IdentityHashMap<A, String>() and then using different instances of A that are equals but are different instances as keys

@lppedd lppedd force-pushed the feat/identity-map branch from d8764e8 to 55bab2f Compare August 26, 2024 08:34
@ftomassetti ftomassetti merged commit 35cb21c into Strumenta:master Aug 29, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants