(require mzlib/integer-set) |
The mzlib/integer-set 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.
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
(difference 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?
x : integer-set? y : integer-set?
procedure
(complement s start end) → any
s : integer-set? start : exact-integer? end : exact-integer?
Returns the a set containing the elements between start to end inclusive that are not in s, where (<= start-k end-k).}
procedure
(xor x y) → integer-set?
x : integer-set? y : integer-set?
procedure
k : exact-integer? s : integer-set?
procedure
(get-integer integer-set) → (or/c exact-integer? false/c)
integer-set : any/c
procedure
(foldr proc base-v s) → any/c
proc : (exact-integer? any/c . -> . any/c) base-v : any/c s : integer-set?
procedure
(partition s) → (listof integer-set?)
s : integer-set-list?
procedure
s : integer-set?
procedure
x : integer-set? y : integer-set?