Set should implement union, intersection, difference and symmetric difference.
morrisonlevi opened this issue · 10 comments
These would be useful for people who are interested in using sets for normal set operations instead of simply storing a bunch of unique values.
I totally agree ... are you also going to add Complements , Cartesian product and ability to check & get Subsets
I will definitely add the check for sub-sets. I could probably do a Complement as well.
I'm not sure how to represent the result of the Cartesian product, so that one would take some designing and maybe some new structures.
I agree about Cartesian product, Another interesting set feature would be Power Sets, The only issue would be performance with large sets but this can be managed with fixed min & max length or introduction of fixed length ....
A relative complement will be easy to implement. Not sure if representing an absolute complement is worthwhile or helpful in a language like PHP.
@morrisonlevi Yes, go with the relative complement. That's the only real complement there is.
Added superset/subset functionality: f14ff53
Well done ..... let me do some testing and see how it performs .....
I highly recommend HashSet for this. SortedSet is abysmal when compared to HashSet. SortedSet is more for maintaining order than anything else.
For most intents and purposes, this is now closed and implemented. If the need arises for some set operation that is currently missing then it deserves its own ticket.