The bit-set Module¶

<bit-set> Primary Class
Superclasses:

`<set>`

Init-Keywords:
• all-members-from – If this is a non-negative integer then the set created will be infinite. All integers greater than or equal to the one supplied will be members of the set. The default is `#f`.

• member-vector

• members – If supplied, this gives the initial elements of the set as a sequence of integers.

• upper-bound-hint – An integer which indicates that all the elements of the set are expected to below this value. This is merely an aid to the implementation when allocating the set, and integers which are greater than or equal to this number can be added at any time. The default is zero.

Discussion:

Represents finite sets and some infinite sets over the non-negative integers in an efficient manner using a `<bit-vector>`. The infinite sets which can be represented are those which are the complement of a finite set.

copy-bit-set! Function
Signature:

copy-bit-set! set1 set2 => ()

Parameters:
Discussion:

Destructively modifies `set1` so that it contains exactly the same elements as `set2`. After the copy, `set1` and `set2` do not share any structure.

empty-bit-set! Function
Signature:

empty-bit-set! set => ()

Parameters:
Discussion:

Destructively modifies `set` by removing all its elements.

infinite? Sealed Generic function
Signature:

infinite? set => result

Parameters:
Values:
Discussion:

Returns `#t` if the set is infinite, otherwise `#f`.

member? Sealed Generic function
Signature:

member? set element => result

Parameters:
Values:
Discussion:

Returns `#t` if `element` is a member of the set, otherwise `#f`. `element` must be a non-negative integer.

Signature:

Parameters:
Values:
Discussion:

Returns a new bit set which includes all the elements in `set` and `element` which must be a non-negative integer.

Signature:

Parameters:
Values:
Discussion:

Modifies `set` to include `element`. The returned set, ```new-set == set```. `element` must be a non-negative integer.

set-complement Sealed Generic function
Signature:

set-complement set => new-set

Parameters:
Values:
Discussion:

Returns a bit-set which represents the complement of the argument set.

set-complement! Sealed Generic function
Signature:

set-complement! set => new-set

Parameters:
Values:
Discussion:

Alters `set` so that it contains the complement of the original set. `new-set == set`.

set-difference Sealed Generic function
Signature:

set-difference set1 set2 => new-set

Parameters:
Values:
Discussion:

Returns a new bit-set whose elements are determined by removing elements from `set1` which are also members of `set2`. Neither `set1` or `set2` will be altered.

set-difference! Sealed Generic function
Signature:

set-difference! set1 set2 => new-set

Parameters:
Values:
Discussion:

Alters `set1` by removing those elements which are also members of `set2`. `new-set == set1`.

set-intersection Sealed Generic function
Signature:

set-intersection set1 set2 => new-set

Parameters:
Values:
Discussion:

Returns a new bit-set containing only elements which appear in both `set1` and `set2`. Neither `set1` or `set2` will be altered.

set-intersection! Sealed Generic function
Signature:

set-intersection! set1 set2 => new-set

Parameters:
Values:
Discussion:

Alters `set1` so that it only contains those elements which are also members of `set2`. `new-set == set1`.

set-remove Sealed Generic function
Signature:

set-remove set element => new-set

Parameters:
Values:
Discussion:

Returns a new bit-set which includes all the elements in `set` except for `element` which must be a non-negative integer.

set-remove! Sealed Generic function
Signature:

set-remove! set element => new-set

Parameters:
Values:
Discussion:

Modifies `set` so that it no longer contains `element`. The returned set, `new-set == set`. `element` must be a non-negative integer.

set-union Sealed Generic function
Signature:

set-union set1 set2 => new-set

Parameters:
Values:
Discussion:

Returns a new bit-set containing every element of `set1` and `set2`. Neither `set1` or `set2` will be altered.

set-union! Sealed Generic function
Signature:

set-union! set1 set2 => new-set

Parameters:
Values:
Discussion:

Alters `set1` so that it also contains the elements in `set2`. `new-set == set1`.

size Sealed Generic function
Signature:

size set => false-or-integer

Parameters:
Values:
Discussion:

Returns the cardinality of the set or `#f` if the set is infinite. This operation may be relatively slow.

universal-bit-set! Function
Signature:

universal-bit-set! set => ()

Parameters:
Discussion:

Destructively modifies `set` to include all non-negative integers as members.