new_sets
Skylib module containing common hash-set algorithms.
An empty set can be created using: sets.make()
, or it can be created with some starting values
if you pass it an sequence: sets.make([1, 2, 3])
. This returns a struct containing all of the
values as keys in a dictionary - this means that all passed in values must be hashable. The
values in the set can be retrieved using sets.to_list(my_set)
.
An arbitrary object can be tested whether it is a set generated by sets.make()
or not with the
types.is_set()
method in types.bzl.
Macros and Functions
sets.make
Creates a new set.
All elements must be hashable.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.make(
)
elements
Optional. Default: None
Optional sequence to construct the set out of.
sets.copy
Creates a new set from another set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.copy(
# A set, as returned by `sets.make()`.
s = None,
)
s
Required.
A set, as returned by sets.make()
.
sets.to_list
Creates a list from the values in the set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.to_list(
# A set, as returned by `sets.make()`.
s = None,
)
s
Required.
A set, as returned by sets.make()
.
sets.insert
Inserts an element into the set.
Element must be hashable. This mutates the original set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.insert(
# A set, as returned by `sets.make()`.
s = None,
# The element to be inserted.
e = None,
)
s
Required.
A set, as returned by sets.make()
.
e
Required.
The element to be inserted.
sets.contains
Checks for the existence of an element in a set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.contains(
# A set, as returned by `sets.make()`.
a = None,
# The element to look for.
e = None,
)
a
Required.
A set, as returned by sets.make()
.
e
Required.
The element to look for.
sets.is_equal
Returns whether two sets are equal.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.is_equal(
# A set, as returned by `sets.make()`.
a = None,
# A set, as returned by `sets.make()`.
b = None,
)
a
Required.
A set, as returned by sets.make()
.
b
Required.
A set, as returned by sets.make()
.
sets.is_subset
Returns whether a
is a subset of b
.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.is_subset(
# A set, as returned by `sets.make()`.
a = None,
# A set, as returned by `sets.make()`.
b = None,
)
a
Required.
A set, as returned by sets.make()
.
b
Required.
A set, as returned by sets.make()
.
sets.disjoint
Returns whether two sets are disjoint.
Two sets are disjoint if they have no elements in common.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.disjoint(
# A set, as returned by `sets.make()`.
a = None,
# A set, as returned by `sets.make()`.
b = None,
)
a
Required.
A set, as returned by sets.make()
.
b
Required.
A set, as returned by sets.make()
.
sets.intersection
Returns the intersection of two sets.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.intersection(
# A set, as returned by `sets.make()`.
a = None,
# A set, as returned by `sets.make()`.
b = None,
)
a
Required.
A set, as returned by sets.make()
.
b
Required.
A set, as returned by sets.make()
.
sets.union
Returns the union of several sets.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.union(
)
args
Optional.
An arbitrary number of sets.
sets.difference
Returns the elements in a
that are not in b
.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.difference(
# A set, as returned by `sets.make()`.
a = None,
# A set, as returned by `sets.make()`.
b = None,
)
a
Required.
A set, as returned by sets.make()
.
b
Required.
A set, as returned by sets.make()
.
sets.length
Returns the number of elements in a set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.length(
# A set, as returned by `sets.make()`.
s = None,
)
s
Required.
A set, as returned by sets.make()
.
sets.remove
Removes an element from the set.
Element must be hashable. This mutates the original set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.remove(
# A set, as returned by `sets.make()`.
s = None,
# The element to be removed.
e = None,
)
s
Required.
A set, as returned by sets.make()
.
e
Required.
The element to be removed.
sets.repr
Returns a string value representing the set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.repr(
# A set, as returned by `sets.make()`.
s = None,
)
s
Required.
A set, as returned by sets.make()
.
sets.str
Returns a string value representing the set.
Example usage (generated):
load("@bazel_skylib//lib:new_sets.bzl", "sets")
sets.str(
# A set, as returned by `sets.make()`.
s = None,
)
s
Required.
A set, as returned by sets.make()
.