difference | Returns the set that would be created by removing from set1 all elements in intersection(set1,set2). |
equals | Returns true if both sets have the same size and contain the same elements. |
hash | Returns the sum of utils.hash(i) for i in set. |
intersection | Computes and returns the intersection of set1 and set2. |
difference | Returns the set that would be created by removing from set1 all elements in intersection(set1,set2). |
removeAll | Equivalent to calling set:remove(e) for e in iter(elements). |
removeElement | Equivalent to set:remove(element). |
retainOnly | Removes all elements from set which do not also appear in elements. |
toString | Returns a string representation of set. |
union | Returns the union of set1 and set2 as a new set. |
uniqueFilter | Create and return a uniqueness filter based on set. |
xor | Returns the set of elements which appear in either set1 or set2, but not in both. |
sets.difference(set1, set2 [,setType])The returned set is created by a call to:
(setType or getmetatable(set1)):new()
synonyms: __sub, minus
sets.equals(set1, set2)This function does not care whether both sets are the same type - a HashSet and SkipSet may be equal according to this function.
sets.hash(set)This is the hash function used by all set implementations.
sets.intersection(set1, set2 [, setType])The returned set is created by a call to:
(setType or getmetatable(set1)):new()
sets.difference(set1, set2 [,setType])The returned set is created by a call to:
(setType or getmetatable(set1)):new()
synonyms: __sub, minus
sets.removeAll(set, elements)
sets.removeElement(set, element)In a sequence, the remove() method takes as input an index while the removeElement method takes as input the element to be removed. This method has the same semantics across both set and sequence implementations.
sets.retainOnly(set, elements)If elements is also a set, s, set is modified to be the intersection of set and s.
sets.toString(set)The order in which elements appear in the representation is the same as the iteration order of elements of the set.
Example:
> print(HashSet:make(1,1,3,2,5,6,4))
{1, 2, 3, 4, 5, 6}
sets.union(set1, set2 [, setType])The returned set is created by a call to:
(setType or getmetatable(set1)):make(...)
synonyms: __add
sets.uniqueFilter(set)The filter is a function which returns true only for objects it has not yet seen. This can be used in conjuction with iter.filter. For example:
> v = vector(1,1,1,2,3,3,4,1,5,5) > print(vector(iter.filter(v, HashSet:uniqueFilter()))) [1, 2, 3, 4, 5]
sets.xor(set1, set2 [,setType])This operation is also often called the symmetric set difference.