I know following things about linkedHashSet
I understand If hashing is used then the concept of bucketing comes in
However, from checking the code in the JDK it seems that LinkedHashSet implementation contains only constructor and no implementation, so I guess all the logic happens in HashSet?
Let me put my question this way ... if objective is to write a collection that
saw a similar question what's the difference between HashSet and LinkedHashSet but not very helpful
Let me know if i need to explain my question more
False. The implementation of LinkedHashSet
is really all in LinkedHashMap
. (And the implementation of HashSet
is really all in HashMap
. Le gasp!)
HashSet
has no linked list at all.
It's entirely possible to write a LinkedSet
collection backed by a linked list, that keeps elements unique -- it's just that its performance will be pretty crappy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With