module Bunch:Collection of elements with fast union.sig..end
type 'a t
val size : 'a t -> int
val empty : 'a t
val is_empty : 'a t -> boolval singleton : 'a -> 'a t
val couple : 'a -> 'a -> 'a t
val imbalance : 'a t -> int
imbalance b >= 0val add : 'a -> 'a t -> 'a t
Bunch.imbalance b <= Bunch.imbalance (add x b) <=
Bunch.imbalance b + 1 Bunch.size (add x b) = 1 + Bunch.size bval add_balanced : 'a -> 'a t -> 'a t
Bunch.imbalance (add_balanced x b) <= Bunch.imbalance <=
Bunch.imbalance (add_balanced x b) + 1 Bunch.size (add_balanced x b) = 1 + Bunch.size bval join : 'a t -> 'a t -> 'a t
Bunch.imbalance
(join b c) = max (max (abs (size b - size c),
Bunch.imbalance b), Bunch.imbalance c)Bunch.size (join a b) = Bunch.size a + Bunch.size bval iter : ('a -> unit) -> 'a t -> unititer f b evaluates f on all the elements of b.
bval iter_const : ('a -> 'b -> unit) -> 'a -> 'b t -> unit
val filter : ('a -> bool) -> 'a t -> 'a tfilter p b is a bunch containing all elements of b that
satisfy predicate b.
Not tail-recursive, but sharing preserving.
val filter_const : ('a -> 'b -> bool) -> 'a -> 'b t -> 'b t
val partition : ('a -> bool) -> 'a t -> 'a t * 'a tpartition p b is a pair of bunches (b1, b2) such that b1
contains all elements of b that satisfy predicate b, and
b2 contains the rest.
Not tail-recursive, but sharing preserving.
val partition_const : ('a -> 'b -> bool) -> 'a -> 'b t -> 'b t * 'b t
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'afold f a b folds f over every element of b using a as an
initial value.
val map : ('a -> 'b) -> 'a t -> 'b tmap f a maps every element of a using f.
val exists : ('a -> bool) -> 'a t -> boolexists p b is true if p x holds for any x in b.
val for_all : ('a -> bool) -> 'a t -> boolfor_all p b is true if p x holds for every x in b. val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list