WeakHashMapCan be easily implemented using a weak box to wrap keys or values within a regular
I didn't consider this a possibility because the other requirements of a Java weak map. For example:
- The values need to potentially be dereferenced/deallocated when the keys go away
- Iteration cannot break if such changes happen due to actions on another thread.
IdentityHashMapCan easily implement using a weak box to wrap keys within a regular
Yes, with an extra step to box/unbox to use. It does have the advantage over java that you can control whether null keys/values are allowed.
It's interesting to note that
IdentityHashMap is a linear probe algorithm, and not a bucket-chain like normal java
P.s. Can you please edit your table to add queue, deque, and stack, for sake of completeness?
As I noted, I left them all off because the whole category has no real Swift equivalents to the Java API. In particular, a lot of the Queue/Deque diversity in Java is based on the early encouragement to use many blocking threads for processing (such as creating a reading and a writing thread for each socket).
If you ignore such concurrency-related methods and go for a simpler API, you can use Array as a Queue. You can use Array directly as a Deque, or wrap it with a more efficient implementation that doesn't necessarily require a full new array/copy to push/pop off the front.
Other options in Java like priority deques don't have an easy corresponding underlying implementation (well, NSSortedMap).
For those reasons I punted on representing it in the table. And punting on representing it was why I made the table and my comments on the table separate posts :-)
If you suggest what to put (Queue/Deque interfaces to nothing on Swift side?), I'll edit the post.