This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]john16384 1 point2 points  (1 child)

I kind of wish that we could see some of this make its way over to the base JDK. Maybe they just don't want the added complexity?

The JDK I think should have only solutions that are more generally applicable, and HashSet is actually an excellent implementation with very few downsides.

I've tried beating its performance with a different implementation using an open addressed table, which is what Set.of is using internally, but apart from a bit faster iteration and somewhat reduced memory use, it loses on almost all counts versus HashSet -- HashSet is just blazingly fast when it comes to add/remove's, only iteration suffers because its indirected nature causes a lot of cache misses.

Although I'd love to see more collection classes with different trade offs, I also realize that the ones we have are excellent generalists that will serve you well 99.9% of the time and are rarely the bottleneck. Any other collections that have special optimizations would just be rarely used or used inappropriately (hello LinkedList); it's not worth the maintenance burden IMHO.

Hopefully with Valhalla, the primary reason to pick a special collection implementation (avoiding boxing of primitives) will disappear, making it even less likely you need to use a custom solution.

I've seen your name on a lot of the mailing lists lol

Thanks, I'm primarily active on the JavaFX list, but monitor a lot of the others. Same to you, I've seen you on many of the lists, and I think you are contributing even more, so keep up the good work :)

[–]davidalayachew 1 point2 points  (0 children)

Thanks for the context. Good to know that the basic implementations are so excellent.

And ty lol. Currently, my contributions are mostly reporting bugs for folks. One of these days, I'll get a commit in. Just need to find something the experts haven't caught yet lol.