Module Code.Set

Sets of codes.

Note. These signatures are the same as those from Stdlib.Set.S but we restrict access to the module in case we want to switch to something less heavy weight for sets of two or three elements.

type t

The type for sets of codes.

val empty : t

empty is the empty set of codes.

val is_empty : t -> bool

empty s is true iff s is empty.

val mem : t -> t -> bool

mem c s is true iff c is in s.

val subset : t -> t -> bool

subset s0 s1 is true iff s0 is a subset of s2.

val cardinal : t -> int

cardinal s is the number of elements in s.

val add : t -> t -> t

add c s is s with c added.

val singleton : t -> t

singelton c is a set made of c.

val remove : t -> t -> t

remove c s is s with c removed.

val union : t -> t -> t

union s0 s1 is the union of s0 and s1.

val inter : t -> t -> t

inter s0 s1 is the intersection of s0 and s1.

val diff : t -> t -> t

diff s0 s1 are the elements of s0 that are not in s2.

val min_elt : t -> t

min_elt s is the minimal element in s note that if Byte is in s then this is Byte.

val of_list : t list -> t

of_list cs is a set containing exactly cs.

val to_list : t -> t list

to_list s is the list of codes in s.

val iter : (t -> unit) -> t -> unit

iter f s iterates f over the elements of s.

val fold : (t -> 'acc -> 'acc) -> t -> 'acc -> 'acc

fold f s acc folds f over the elements of s starting with acc.

val pp : t B0_std.Fmt.t

pp formats sets.

val pp_human : t B0_std.Fmt.t

pp_human is a sentence of the form "codes a, b, c"