# (lispkit bitset)

Library

`(lispkit bitset)`

implements bit sets of arbitrary size. Bit sets are mutable objects. The API of library `(lispkit bitset)`

provides functionality to create, to inspect, to compose, and to mutate bit sets efficiently.**(bitset?**

*obj***)**

Returns

`#t`

if *obj*is a bit set,`#f`

otherwise.**(bitset**

*i ...***)**

Returns a new bit set with bits

*i ...*set. Each*i*is a fixnum referring to one bit in the bit set by its ordinality.**(list->bitset**

*list***)**

Returns a new bit set with bits specified by

*list*. Each element in*list*is a fixnum referring to one bit in the bit set by its ordinality.**(bitset-copy**

*bs***)**

Returns a copy of bit set

*bs*.**(bitset-size**

*bs***)**

Returns the number of bits set in bit set

*bs*.**(bitset-next**

*bs***)**

**(bitset-next**

*bs i***)**

Returns the next bit set in

*bs*following bit*i*. If*i*is not provided, the first bit set in*bs*is returned.**(bitset-empty?**

*bs***)**

Returns

`#t`

if bit set *bs*is empty,`#f`

otherwise.**(bitset-disjoint?**

*bs1 bs2***)**

Returns

`#t`

if bit sets *bs1*and*bs2*are disjoint,`#f`

otherwise.**(bitset-subset?**

*bs1 bs2***)**

Returns

`#t`

if bit set *bs2*is a subset of bit set*bs2*,`#f`

otherwise.**(bitset-contains?**

*bs i ...***)**

Returns

`#t`

if all bits *i ...*are set in bit set*bs*,`#f`

otherwise.**(bitset-adjoin!**

*bs i ...***)**

Inserts the bits

*i ...*into bit set*bs*.`bitset-adjoin!`

returns *bs*.**(bitset-adjoin-all!**

*bs list***)**

Inserts all the bits specified by

*list*into bit set*bs*. Each element in*list*is a fixnum referring to one bit in the bit set by its ordinality.`bitset-adjoin-all!`

returns *bs*.**(bitset-delete!**

*bs i ...***)**

Removes the bits

*i ...*from bit set*bs*.`bitset-delete!`

returns *bs*.**(bitset-delete-all!**

*bs list***)**

Removes all the bits specified by

*list*from bit set*bs*. Each element in*list*is a fixnum referring to one bit in the bit set by its ordinality.`bitset-delete-all!`

returns *bs*.**(bitset-union!**

*bs bs1 ...***)**

Computes the union of bit sets

*bs*,*bs1 ...*and stores the result in*bs*.`bitset-union!`

returns *bs*.**(bitset-intersection!**

*bs bs1 ...***)**

Computes the intersection of bit sets

*bs*,*bs1 ...*and stores the result in*bs*.`bitset-intersection!`

returns *bs*.**(bitset-difference!**

*bs bs1 ...***)**

Computes the difference between bit sets

*bs*and*bs1 ...*and stores the result in*bs*.`bitset-difference!`

returns *bs*.**(bitset-xor!**

*bs bs1 ...***)**

Computes the exclusive disjunction of bit sets

*bs*,*bs1 ...*and stores the result in*bs*.`bitset-xor!`

returns *bs*.**(bitset=?**

*bs bs1 ...***)**

Returns

`#t`

if the bit sets *bs*,*bs1 ...*are all equal, i.e. have the same bits set. Otherwise`#f`

is returned.**(bitset<?**

*bs bs1 ...***)**

Returns

`#t`

if *bs*is a proper subset of*bs1*, and*bs1*is a proper subset of*bs2*, etc. Otherwise`#f`

is returned.**(bitset>?**

*bs bs1 ...***)**

Returns

`#t`

if *bs*is a proper superset of*bs1*, and*bs1*is a proper superset of*bs2*, etc. Otherwise`#f`

is returned.**(bitset<=?**

*bs bs1 ...***)**

Returns

`#t`

if *bs*is a subset of*bs1*, and*bs1*is a subset of*bs2*, etc. Otherwise`#f`

is returned.**(bitset>=?**

*bs bs1 ...***)**

Returns

`#t`

if *bs*is a superset of*bs1*, and*bs1*is a superset of*bs2*, etc. Otherwise`#f`

is returned.**(bitset->list**

*bs***)**

Returns a list of all bits set in

*bs*.**(bitset-for-each**

*proc bs***)**

Invokes

*proc*on each bit set in*bs*in increasing ordinal order.**(bitset-fold**

*proc z bs***)**

The current state is initialized to z, and

*proc*is invoked on each bit of*bs*in increasing ordinal order and the current state, setting the current state to the result. The algorithm is repeated until all the bits of*bs*have been processed. Then the current state is returned.**(bitset-any?**

*pred bs***)**

Returns

`#t`

if any application of *pred*to the bits of*bs*returns true, and`#f`

otherwise.**(bitset-every?**

*pred bs***)**

Returns

`#t`

if every application of *pred*to the bits of*bs*returns true, and`#f`

otherwise.**(bitset-filter**

*pred bs***)**

Returns a new bit set containing the bits from

*bs*that satisfy*pred*.**(bitset-filter!**

*pred bs***)**

Removes all bits from

*bs*for which*pred*returns`#f`

.Last modified 11mo ago