# (chibi iset iterators)

#### `(iset-empty? iset)`

Returns true iff `iset` is empty.

#### `(iset-cursor iset [stack])`

Create a new iset cursor pointing to the first element of iset, with an optional stack argument.

#### `(iset-cursor-next iset cur)`

Return a new iset cursor pointing to the next element of `iset` after `cur`. If `cur` is already at `end-of-iset?`, the resulting cursor is as well.

#### `(iset-ref iset cur)`

Return the element of iset `iset` at cursor `cur`. If the cursor is at `end-of-iset?`, raises an error.

#### `(end-of-iset? cur)`

Returns true iff `cur` is at the end of iset, such that `iset-ref` is no longer valid.

#### `(iset-rank iset element)`

Returns the rank (i.e. index within the iset) of the given element, a number in [0, size). This can be used to compress an integer set to a minimal consecutive set of integets. Can also be thought of as the number of elements in iset smaller than element.

#### `(iset-select iset index)`

Selects the index-th element of iset starting at 0. The inverse operation of `iset-rank`.

#### `(iset= . o)`

Returns true iff all arguments contain the same elements. Always returns true if there are less than two arguments.

#### `(iset<= . o)`

Returns true iff the arguments are monotonically increasing, that is each argument contains every element of all preceding arguments. Always returns true if there are less than two arguments.

#### `(iset>= . o)`

Returns true iff the arguments are monotonically decreasing, that is each argument contains every element of all succeeding arguments. Always returns true if there are less than two arguments.

#### `(iset-fold-node kons knil iset)`

#### `(iset-fold kons knil iset)`

The fundamental iset iterator. Applies `kons` to every element of `iset` along with an accumulator, starting with `knil`. Returns `knil` if `iset` is empty.

#### `(iset-for-each-node proc iset)`

#### `(iset-for-each proc iset)`

Runs `proc` on every element of iset, discarding the results.

#### `(iset->list iset)`

Returns a list of every integer in `iset` in sorted (increasing) order.

#### `(iset-size iset)`

Returns the number of elements in `iset`.