The elements of an integer set are exact integers. The procedures for creating and manipulating integer sets are the same as those for SRFI 113 sets, except that set
is replaced by integer-set
in their names. However, set-comparator
has no equivalent for integer sets, and in integer-set
, integer-set-unfold
, integer-set-map
, and integer-set-copy
the comparator argument is omitted.
Although sets subsume integer sets, providing them separately allows for increased implementation efficiency. There are two Chicken eggs that provide integer sets: iset
, which is conceptually similar to the integer sets described here; and cis
, which uses lists of integer intervals.
(range->integer-set
low high)
Returns a newly allocated integer set. The set contains the elements from low (inclusive) to high (exclusive).
(integer-set-adjoin-range
integer-set low high)
Returns a newly allocated integer set that contains all its values, and in addition each integer from low (inclusive) to high (exclusive) unless it is already equal to an existing member.
(integer-set-adjoin-range!
integer-set low high)
A linear update procedure that returns an integer set that contains all its values, and in addition each integer from low (inclusive) to high (exclusive) unless it is already equal to an existing member.
(integer-set-complement
integer-set)
Returns a newly allocated integer set that is the complement of integer-set.
(integer-set-min
integer-set)
(integer-set-max
integer-set)
Returns the smallest or largest integer in integer-set, or #f
if there is none.
(integer-set-open-interval
integer-set low high)
(integer-set-closed-interval
integer-set low high)
(integer-set-open-closed-interval
integer-set low high)
(integer-set-closed-open-interval
integer-set low high)
Procedures that return a subset of integer-set contained in the interval from low to high. The interval may be open, closed, open below and closed above, or open above and closed below.
(integer-set-range=
integer-set k)
(integer-set-range<
integer-set k)
(integer-set-range<=
integer-set k)
(integer-set-range>
integer-set k)
(integer-set-range>=
integer-set k)
Procedures that return an integer set containing the elements of integer-set that are equal
to, less than, less than or equal to, greater than, or greater than or equal to k.
Note that the result integer-set-range=
contains at most one element.
(integer-set-delete-min!
integer-set)
(integer-set-delete-max!
integer-set)
Linear update procedures that return two values: the smallest or largest integer in integer-set or #f
if there is none, and a set which contains all the elements of set except the integer being returned.