8 Integer Sets
(require data/integer-set) |
This library provides functions for working with finite sets of integers. This module is designed for sets that are compactly represented as groups of intervals, even when their cardinality is large. For example, the set of integers from -1000000 to 1000000 except for 0, can be represented as {[-1000000, -1], [1, 1000000]}. This data structure would not be a good choice for the set of all odd integers between 0 and 1000000, which would be {[1, 1], [3, 3], ... [999999, 999999]}.
In addition to the integer set abstract type, a well-formed set is a list of pairs of exact integers, where each pair represents a closed range of integers, and the entire set is the union of the ranges. The ranges must be disjoint and increasing. Further, adjacent ranges must have at least one integer between them. For example: '((-1 . 2) (4 . 10)) is a well-formed-set as is '((1 . 1) (3 . 3)), but '((1 . 5) (6 . 7)), '((1 . 5) (-3 . -1)), '((5 . 1)), and '((1 . 5) (3 . 6)) are not.
An integer set implements the stream and sequence generic interfaces.
procedure
(make-integer-set wfs) → integer-set?
wfs : well-formed-set?
procedure
s : integer-set?
procedure
(set-integer-set-contents! s wfs) → void?
s : integer-set? wfs : well-formed-set?
procedure
(integer-set? v) → boolean?
v : any/c
procedure
(well-formed-set? v) → boolean?
v : any/c
procedure
(make-range elem) → integer-set? elem : exact-integer? (make-range start end) → integer-set? start : exact-integer? end : exact-integer?
procedure
(intersect x y) → integer-set?
x : integer-set? y : integer-set?
procedure
(subtract x y) → integer-set?
x : integer-set? y : integer-set?
procedure
(union x y) → integer-set?
x : integer-set? y : integer-set?
procedure
(split x y) →
integer-set? integer-set? integer-set? x : integer-set? y : integer-set?
procedure
(complement s start end) → integer-set?
s : integer-set? start : exact-integer? end : exact-integer?
procedure
(symmetric-difference x y) → integer-set?
x : integer-set? y : integer-set?
procedure
k : exact-integer? s : integer-set?
procedure
(get-integer set) → (or/c exact-integer? #f)
set : integer-set?
procedure
proc : (exact-integer? any/c . -> . any/c) base-v : any/c s : integer-set?
procedure
(partition s) → (listof integer-set?)
s : (listof integer-set?)
procedure
s : integer-set?
procedure
x : integer-set? y : integer-set?