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
Map values, giving both key and value. Will use WORD
.of_list to rebuild keys.
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
.
Randomly choose a (key,value) pair within the tree, using weights as probability weights.