#
cp.collect.Set
An implementation of a logical set
, which contains a single unique
reference of each item in it. For example:
Set(1,2,2,3) == Set(1,1,2,3,3) == Set(1,2,3)
You can combine sets in a couple of ways. For example, a union
:
Set(1,2):union(Set(2,3)) == Set(1,2,3)
Set(1,2) | Set(2,3) == Set(1,2,3)
...or an intersection
:
Set(1,2):intersection(Set(2,3)) == Set(2)
Set(1,2) & Set(2,3) == Set(2)
As indicated above, you can use operators for common set operations. Specifically:
union (A ⋃ B):a | b
ora + b
intersection (A ∩ B):a & b
complement (Ac):-a
difference (A - B):a - b
symetric difference (A ⊕ B)a ~ b
Keep in mind that Lua's operator precedence may be different to that of standard set operations, so it's probably best to group operations in brackets if you combine more than one in a single statement. For example:
a + b | c ~= a + (b | c)
#
API Overview
Constants - Useful values which cannot be changed
everything nothing
Functions - API calls offered directly by the extension
complement difference has intersection is isComplement size symetricDifference union
Constructors - API calls which return an object, typically one that offers API methods
clone fromList fromMap of
Methods - API calls which can only be made on an object returned by a constructor
complement difference has intersection isComplement size symetricDifference union
#
API Documentation
#
Constants
#
everything
#
nothing
#
Functions
#
complement
#
difference
#
has
#
intersection
#
is
#
isComplement
#
size
#
symetricDifference
#
union
#
Constructors
#
clone
#
fromList
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | cp.collect.Set.fromList(list) -> cp.collect.Set
|
| Type | Constructor |
| Description | Creates a new Set
instance, containing the unique items in the table collected as a list from 1
to n
. Any duplicate items will only occur in the Set
once. |
| Parameters |
- list - The table that contains items as a list to add to the
Set
. E.g.{"foo", "bar"}</li></ul> | | **Returns** | <ul><li>The new
Set`.