Sets
Last updated
Last updated
Operators and functions for working with an array of boolean values (set type) are described here.
The arr function converts a set value to an array of integers that contains indexes of set items.
The set function converts a string to a set value and returns it. The string must only have 1 and 0 characters.
The set function converts an array of integers to a set value and returns it. The result set will have items with corresponding indexes.
The str function converts a set value to a string and returns it. The result string contains only 1 and 0.
The Set function adds an index item to the set. It is the same as s[index] = true. The function returns s.
The Toggle function adds an index item to the set if the set doesn't have it and otherwise, the function removes the item. It is the same as s[index] = !s[index]. The function returns the previous state - true if the item existed and, otherwise, false.
The UnSet function removes an index item from the set. It is the same as s[index] = false. The function returns s.
Operator
Result
Description
* set
int
Returns the set size.
^ set
set
Returns a new set as logical NOT of the source set. !s[i] for each item.
set = set
set
Assignment operator.
set &= set
set
Create a clone of the set. The new variable will work with the same data set.
set += set
set
Appends a set to a set variable.
set & set
set
Returns a set that is the intersection of two sets. left[i] && right[i] for each item.
set | set
set
Returns a set that is the union of two sets. left[i] || right[i] for each item.
set [ int ]
bool
Sets/gets a set value.