123
rated 0 times
[
126]
[
3]
/ answers: 1 / hits: 120843
/ 15 Years ago, thu, november 12, 2009, 12:00:00
Let A
and B
be two sets. I'm looking for really fast or elegant ways to compute the set difference (A - B
or A B
, depending on your preference) between them. The two sets are stored and manipulated as Javascript arrays, as the title says.
Notes:
- Gecko-specific tricks are okay
- I'd prefer sticking to native functions (but I am open to a lightweight library if it's way faster)
- I've seen, but not tested, JS.Set (see previous point)
Edit: I noticed a comment about sets containing duplicate elements. When I say set I'm referring to the mathematical definition, which means (among other things) that they do not contain duplicate elements.
More From » arrays