CCWBTree.Make
type key = X.t
val empty : 'a t
val is_empty : _ t -> bool
nth i m
returns the i
-th key, value
in the ascending order. Complexity is O(log (cardinal m))
.
get_rank k m
looks for the rank of k
in m
, i.e. the index of k
in the sorted list of bindings of m
. let (`At n) = get_rank k m in nth_exn n m = get m k
should hold.
update k f m
calls f (Some v)
if get k m = Some v
, f None
otherwise. Then, if f
returns Some v'
it binds k
to v'
, if f
returns None
it removes k
.
val cardinal : _ t -> int
val weight : _ t -> int
split k t
returns l, o, r
where l
is the part of the map with keys smaller than k
, r
has keys bigger than k
, and o = Some v
if k, v
belonged to the map.
extract_min m
returns k, v, m'
where k,v
is the pair with the smallest key in m
, and m'
does not contain k
.
extract_max m
returns k, v, m'
where k,v
is the pair with the highest key in m
, and m'
does not contain k
.
val random_choose : Stdlib.Random.State.t -> 'a t -> key * 'a
Randomly choose a (key,value) pair within the tree, using weights as probability weights.