Set
Implementation of set.
Set:__init(values)
Constructor.
Arguments:
values
(table[any]
): used to initialize the set. Optional.
Set.keyOf(val)
Arguments:
val
(any
): value to produce a key for.
Returns:
- (
torch.pointer
) unique key for the value
Set:size()
Returns:
- (
int
) number of values in the set
Set:add(val)
Adds a value to the set.
Arguments:
val
(any
): value to add to the set.
Returns:
- (
Set
) modified set
Set:addMany(...)
Adds a variable number of values to the set.
Arguments:
vararg
(vararg
): values to add to the set.
Returns:
- (
Set
) modified set
Set:copy()
Returns:
- (
Set
) copy of the set
Set:contains(val)
Arguments:
val
(any
): value to check for.
Returns:
- (
boolean
) whether the set containsval
Set:remove(val)
Arguments:
val
(any
): value to remove from the set.
Returns:
- (
Set
) modified set Ifval
is not found then an error is raised.
Set:totable()
Returns:
- (
tabl
) the set in table format
Set:equals(another)
Compares two sets.
Arguments:
another
(Set
): another set.
Returns:
- (
boolean
) whether this set andanother
contain the same values
Set:union(another)
Computes the union of two sets.
Arguments:
another
(Set
): another set.
Returns:
- (
Set
) a set of values that are in this set or inanother
Set:intersect(another)
Computes the intersection of two sets.
Arguments:
another
(Set
): another set.
Returns:
- (
Set
) a set of values that are in this set and inanother
Set:subtract(another)
Subtracts another set from this one.
Arguments:
another
(Set
): another set.
Returns:
- (
Set
) a set of values that are in this set but not inanother
Set:__tostring__()
Returns:
- (
string
) string representation