Module Bogue.Selection

module Selection: sig .. end

Unions of ranges of integers

Example

We define two sets, s=[0..5; 10..20] and r=[4..15], and we compute their union and intersection.

open Bogue.Selection;;
# let s = of_list [(0,5); (10,20)];;
val s : t = <abstr>
# sprint s;;
- : string = "{0..5, 10..20}"
# let r = of_list [(4,15)];;
val r : t = <abstr>
# sprint (union s r);;
- : string = "{0..20}"
# sprint (intersect s r);;
- : string = "{4..5, 10..15}"
Dependency graph

type t 
val empty : t
val is_empty : t -> bool
val size : t -> int

Number of selected integers

val to_list : t -> (int * int) list
val of_list : (int * int) list -> t
val range : int * int -> t
val first : t -> int
val last : t -> int
val mem : t -> int -> bool
val toggle : t -> int -> t
val remove : t -> int -> t
val add : t -> int -> t
val union : t -> t -> t

Not tail-recursive

val intersect : t -> t -> t

Not tail-recursive

val invert : first:int -> last:int -> t -> t

invert ~first ~last sel returns a selection containing all integers not selected in sel, withing the range [first, last].

val sprint : t -> string
val iter : (int -> unit) -> t -> unit