module Avltree: Avltree
type ('k, 'v)
t =
| |
Empty |
| |
Node of |
| |
Leaf of |
val empty : ('k, 'v) t
val invariant : ('k, 'v) t -> compare:('k -> 'k -> int) -> unit
val add : ?replace:bool ->
('k, 'v) t ->
compare:('k -> 'k -> int) ->
added:bool Pervasives.ref -> key:'k -> data:'v -> ('k, 'v) t
replace
(default true) is true then add will
overwrite any existing mapping for key
. If replace
is false, and there is an
existing mapping for key then add has no effect.val first : ('k, 'v) t -> ('k * 'v) option
val last : ('k, 'v) t -> ('k * 'v) option
val find : ('k, 'v) t -> compare:('k -> 'k -> int) -> 'k -> 'v option
val find_and_call : ('k, 'v) t ->
compare:('k -> 'k -> int) ->
'k -> if_found:('v -> 'a) -> if_not_found:('k -> 'a) -> 'a
find_and_call t ~compare k ~if_found ~if_not_found
is equivalent to:
match find t ~compare k with Some v -> if_found v | None -> if_not_found k
except that it doesn't allocate the option.
val mem : ('k, 'v) t -> compare:('k -> 'k -> int) -> 'k -> bool
val remove : ('k, 'v) t ->
removed:bool Pervasives.ref ->
compare:('k -> 'k -> int) -> 'k -> ('k, 'v) t
val fold : ('k, 'v) t -> init:'a -> f:(key:'k -> data:'v -> 'a -> 'a) -> 'a
val iter : ('k, 'v) t -> f:(key:'k -> data:'v -> unit) -> unit