Returns true iff s is empty. O(1).
Returns an empty set of the same type and organization as c.
Returns an arbitrary element of s. Specifically, on a nonempty set, returns two values: an arbitrary element and true; on an empty set, returns two false values. O(1).
Returns true iff x is an element of s. O(log n).
If s contains x, returns two values, true and the element found; else false and
nil. (This is useful for canonicalizing instances; the element found may be a different
instance from x.) O(log n).
Returns a set, of the same class and organization as s, that contains all elements of s
and also x. If s already contained a value equal to x, according to its
comparison function, returns s itself. (This is so you can find out whether the element was
added simply by calling eq on s and the result.) O(log n).
A modify macro that expands to with. If place s
(which must be setf-able) holds a set, updates it so the set now contains x.
Returns a set, of the same class and organization as s, that contains all elements of s
except x. If s did not contain a value equal to x, according to its comparison
function, returns s itself. (This is so you can find out whether the element was removed
simply by calling eq on s and the result.) O(log n).
A modify macro that expands to less. If place s
(which must be setf-able) holds a set, updates it so the set does not contain x.
If s contains x, returns the index of x within the ordering of s; otherwise
nil. O(log n).
Returns the element at index idx within the ordering of s. (On a wb-set, this is
the same as at-rank.) idx must be in [0 .. size(s)); otherwise, signals an error of
type simple-type-error. O(log n).
Returns a set of the same type and organization as s1, that contains all elements that are in either s1 or s2. Implements left preference: for any pair of equal objects in the two sets, the result contains the instance that was in s1. Normally O(n).
A modify macro that expands to union. If place s1
(which must be setf-able) holds a set, updates it so the set now contains all elements of
s2.
Returns a set of the same type and organization as s1, that contains all elements that are in both s1 and s2. Implements left preference: for any pair of equal objects in the two sets, the result contains the instance that was in s1. Normally O(n).
A modify macro that expands to intersection. If place
s1 (which must be setf-able) holds a set, updates it so the set now contains only
elements that are also in s2.
Returns a set of the same type and organization as s1, that contains all elements that are in s1 and not in s2. Normally O(n).
Returns, as two values: () a set of the same type and organization as s1, that contains all elements that are in s1 and not in s2, and () a set of the same type and organization as s2, that contains all elements that are in s2 and not in s1. Normally O(n).
Returns true iff every element of s1 is also in s2. Normally O(n).
Returns true iff every element of s1 is also in s2, and s1 is smaller than s2. Normally O(n).
Returns true iff s1 and s2 have no elements in common. Normally O(n).
For each element of set, binds var to it and executes body. When done,
returns value if supplied, otherwise nil.
Returns a stateful iterator over the set. The :get operation
returns two values: if there is another element remaining, returns it and a true second value, else
nil and false. Creating an iterator takes O(log n) time; the :get operation is
amortized O(1).
Returns a functional iterator over the set. The :first
operation returns two values: if the iterator is not empty, returns the first element and a true
second value, else nil and false. Creating an iterator takes O(log n) time; the
:first operation is O(1), and :rest is amortized O(1).
Returns a new set, of the same type and organization as s, containing only those elements that satisfy pred. pred must be a function, an fbound symbol, or a boolean-valued map. O(n ⋅ tc(pred)) + O(r log r), where tc(pred) is the time complexity of pred and r is the size of the result.
Equivalent to (values (filter pred s) (filter (complement pred) s)) when pred is a
function. Returns two values: first, a new set, of the same type and organization as s,
containing only those elements that satisfy pred; second, a similar set containing only those
elements that do not satisfy pred. pred must be a function, an fbound symbol, or
a boolean-valued map. O(n ⋅ tc(pred)) + O(r log r), where tc(pred) is the
time complexity of pred and r is the size of the result.
Returns a set containing the values of fn applied to all the elements of s. Since the result is a set, its elements will not necessarily correspond one-to-one to those of s; it will impose its own ordering, and will be smaller than s if fn returns the same value on two or more elements of s. The result will be of the same type as s. compare-fn-name, if supplied, will control its organization; otherwise, that will also be the same as for s. fn must be a function, an fbound symbol, or a map. O(n ⋅ tc(fn)) + O(r log r), where tc(fn) is the time complexity of fn and r is the size of the result.
A modify macro that expands to image. If place s
(which must be setf-able) holds a set, updates it so the place now contains the image of the
set under fn.
Calls fn repeatedly with two arguments, a state variable and the next element of s,
storing the result of each call back into the state variable, and finally returning that result. If
initial-value is supplied, it is used as the initial value of the state variable. Otherwise:
if s is nonempty, the initial value is the first element; if s is empty, the result of
reduce is obtained by calling fn with no arguments. In all cases, if key is
provided, it is called on each element and the result used in place of the element. (Time
complexity depends on the behavior of fn.)
Scans linearly through s to find an element that matches item according to key and
test. For each element of s, key, a function that defaults to the identity
function, is called on it, and then test is called on item and the result; if it returns
true, find returns the element. If no match is found, find returns nil.
test defaults to equal?, not eql.
Normally O(n), but as a special case, if test is equal?, key is not supplied,
and the set’s comparison function is compare, this does an O(log n) lookup.
Scans linearly through s to find an element for which the result of calling key on it
satisfies pred. key and pred must be functions or fbound symbols. key
defaults to the identity function. Returns the element found, or nil if none.
Scans linearly through s to find an element for which the result of calling key on it
does not satisfy pred. key and pred must be functions or fbound symbols.
key defaults to the identity function. Returns the element found, or nil if none.
Scans linearly through s, counting the number of elements that match item according to
key and test. For each element of s, key is called on it, and then
test is called on item and the result; if it returns true, the element is counted.
Returns the count. key and test must be functions or fbound symbols. key defaults
to the identity function; test defaults to equal?, not eql.
Normally O(n), but as a special case, if test is equal?, key is not supplied,
and the set’s comparison function is compare, this does an O(log n) lookup to return 0 or
1.
Scans linearly through s to count the elements for which the result of calling key on them satisfies pred. Returns the count. pred and key must be functions or fbound symbols. key defaults to the identity function.
Scans linearly through s to count the elements for which the result of calling key on them does not satisfy pred. Returns the count. pred and key must be functions or fbound symbols. key defaults to the identity function.