sets

A module providing Sets. The sets are pretty much the same as python sets.

module exceptions

  • ItemNotFoundInSet - Thrown if the item could not be found in the set.

module classes

Set(arrayOrItem1=null, item2) - A class that implements set functionality. All Items added to a set must have an id returned by jsolait's id() function.

  • arrayOrItem1 - If there is only one argument passed to the constructor then it is treated as an Array and all its items are added to the new Set instance.
  • item2 - if there are more than 1 argument passed to the constructor all the arguments are added as items to the new Set.

  • Set::add(item) - Adds an item to the set and returns it.
  • Set::remove(item) - Removes an item to the set and returns it or throws an ItemNotFoundInSet exceptions if the item does not exist.
  • Set::discard(item) - Removes an item to the set and returns it or returns undefined if it does not exist.
  • Set::contains(item) - Returns true if the set contains the item, otherwise false.
  • Set::isSubset(setObj) - Returns true if the set is a subset of setObj, else false.
  • Set::isSuperset(setObj) - Returns true if the set is a superset of setObj, else false.
  • Set::equals(setObj) - Returns true if the set equal setObj(i.e. it contains the same items), else false.
  • Set::union(setObj) - Creates a new set containing all elements of set and setObj (newSet = set | setObj).
  • Set::unionUpdate(setObj) - Updates the set adding all elements from setObj (set = set | setObj).
  • Set::intersection(setObj) - Updates the set containing elements common to the set and setObj (set = set & setObj).
  • Set::intersectionUpdate(setObj) - Creates a new set containing elements common to the set and setObj (newSet = set & setObj).
  • Set::difference(setObj) - Creates a new set containing only elements of the set that are not found in setObj (newSet = set - setObj).
  • Set::differenceUpdate(setObj) - Updates the set removing all elements found in setObj (set = set - setObj).
  • Set::symmDifference(setObj) - Creates a new set containing elements from the set and setObj but no elements present in both(newSet = (set - setObj) | (setObj - set)).
  • Set::symmDifferenceUpdate(setObj) - Updates the set to only contain elements from the set and setObj but no elements present in both(set = (set - setObj) | (setObj - set)).
  • Set::copy() - Creates a shallow copy of the set and returns it.