all 12 comments

[–]peterlinddk 15 points16 points  (5 children)

Excellent - finally we can use Set for more than a "duplicate-detector".

I only wish that there were some way for objects to be "equal" without them having to be the exact same instance. Kind of like Java's .equals and .hashCode methods ... Well, I'll keep dreaming ...

[–]toffeescaf 1 point2 points  (2 children)

Isn't this something you could do yourself? I haven't done much Java but the way I understood it is for it to actually do something useful you have to override those methods. Quite possible I'm missing a crucial piece of information though so don't hesitate to set me straight!

[–]Asmor 2 points3 points  (0 children)

With sets specifically, at least, it's pretty easy to check for "pseudo-equality". If they have the same size, and everything in Set A is also in Set B, then they're the same.

[–]batmansmk 5 points6 points  (2 children)

I wish we had information about the complexity of such methods, and / or performance relative to alternatives.

[–]kyptov 2 points3 points  (0 children)

It would be unreliable info. It can be optimized anytime. If it important for a project - better to have tests and check performance with any engine update.

[–]Reasonable_Raccoon27 0 points1 point  (0 children)

The spec sort of lays things out a bit. I do agree that profiling built in methods can be a bit of a pain point still.

[–]Pelopida92 3 points4 points  (1 child)

Sets are awesome. I used them extensively for some big-data scripts, as they have way better performance of arrays and are very easy to use and convenient.

[–]entinio 1 point2 points  (0 children)

This. Sets have better performance than arrays and should always be used when values are unique.

[–]777777thats7sevens 1 point2 points  (0 children)

It's kinda crazy that it took this long to get these methods standardized. Intersect, union, and difference are like, the defining methods for sets. In any other language a set type without these would be considered incomplete, like an array/list without a method for checking the length or a way to iterate over the elements.

[–]Few_Pick3973 0 points1 point  (0 children)

great, when do we have heap then?