Set

Implementation of set.

Set:__init(values)

View source

Constructor.

Arguments:

  • values (table[any]): used to initialize the set. Optional.

Set.keyOf(val)

View source

Arguments:

  • val (any): value to produce a key for.

Returns:

  • (torch.pointer) unique key for the value

Set:size()

View source

Returns:

  • (int) number of values in the set

Set:add(val)

View source

Adds a value to the set.

Arguments:

  • val (any): value to add to the set.

Returns:

  • (Set) modified set

Set:addMany(...)

View source

Adds a variable number of values to the set.

Arguments:

  • vararg (vararg): values to add to the set.

Returns:

  • (Set) modified set

Set:copy()

View source

Returns:

  • (Set) copy of the set

Set:contains(val)

View source

Arguments:

  • val (any): value to check for.

Returns:

  • (boolean) whether the set contains val

Set:remove(val)

View source

Arguments:

  • val (any): value to remove from the set.

Returns:

  • (Set) modified set If val is not found then an error is raised.

Set:totable()

View source

Returns:

  • (tabl) the set in table format

Set:equals(another)

View source

Compares two sets.

Arguments:

  • another (Set): another set.

Returns:

  • (boolean) whether this set and another contain the same values

Set:union(another)

View source

Computes the union of two sets.

Arguments:

  • another (Set): another set.

Returns:

  • (Set) a set of values that are in this set or in another

Set:intersect(another)

View source

Computes the intersection of two sets.

Arguments:

  • another (Set): another set.

Returns:

  • (Set) a set of values that are in this set and in another

Set:subtract(another)

View source

Subtracts another set from this one.

Arguments:

  • another (Set): another set.

Returns:

  • (Set) a set of values that are in this set but not in another

Set:__tostring__()

View source

Returns:

  • (string) string representation