function set.add
Add an item to the set.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) x.add(4) x == set([1, 2, 3, 4]) # "#);
function set.clear
function set.difference
Returns a new set with elements unique the set when compared to the specified iterable.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) y = [3, 4, 5] x.difference(y) == set([1, 2]) # "#);
function set.discard
Remove the item from the set. It does nothing if there is no such item.
discard fails if the key is unhashable or if the dictionary is
frozen.
Time complexity of this operation is O(N) where N is the number of entries in the set.
x.discard(2) would do nothing.
function set.intersection
Return a new set with elements common to the set and all others. Unlike Python does not support variable number of arguments.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) y = [3, 4, 5] x.intersection(y) == set([3]) # "#);
function set.issubset
Test whether every element in the set is in other iterable.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) y = [3, 1, 2] x.issubset(y) # "#);
function set.issuperset
Test whether every element other iterable is in the set.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) y = [1, 3] x.issuperset(y) == True # "#);
function set.pop
Removes and returns the last element of a set.
S.pop() removes and returns the last element of the set S.
pop fails if the set is empty, or if the set is frozen or has active iterators.
Time complexity of this operation is O(1).
function set.remove
Remove the item from the set. It raises an error if there is no such item.
remove fails if the key is unhashable or if the dictionary is
frozen.
Time complexity of this operation is O(N) where N is the number of entries in the set.
x.remove(2) would yield an error because the
element won’t be found.
function set.symmetric_difference
Returns a new set with elements in either the set or the specified iterable but not both.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) y = [3, 4, 5] x.symmetric_difference(y) == set([1, 2, 4, 5]) # "#);
function set.union
Return a new set with elements from the set and all others. Unlike Python does not support variable number of arguments.
# starlark::assert::is_true(r#" x = set([1, 2, 3]) y = [3, 4, 5] x.union(y) == set([1, 2, 3, 4, 5]) # "#);
function set.update
Update the set by adding items from an iterable.
# starlark::assert::is_true(r#" x = set([1, 3, 2]) x.update([4, 3]) list(x) == [1, 3, 2, 4] # "#);
