/set-js

implementation for a Set type which supports union, intersection, etc.

Primary LanguageJavaScript

A Set data type with the following methods.

  + add
  + clear
  + copy
  + contains
  + difference
  + differenceUpdate
  + foreach
  + fromArray
  + intersection
  + intersectionUpdate
  + isDisjoint
  + isSubset
  + isSuperset
  + remove
  + size
  + symmetricDifference
  + toArray  	
  + union
  + unionUpdate
  
 example:
 var set1 = new Set()
 var set2 = new Set()
 set1.fromArray([1, 2, 3])
 set2.fromArray([3, 4, 5])

 set1.union(set2)        => Set<1, 2, 3, 4, 5>
 set1.intersection(set2) => Set<3>

 see tests.js for more examples;