module Hashmmap: sig
.. end
Module implementing polymorphic unbounded multi maps (environments).
val default_size : int
The default size of the hash used in the implementation
class [['a, 'b]]
hashmultimap : ?size:int -> unit ->
object
.. end
The hashmultimap class
type ('a, 'b)
t = ('a, 'b) hashmultimap
The abstract type of an hashmmap.
val make : ?size:int -> unit -> ('a, 'b) t
The hashmmap constructor.
val lookup_or_fail : ('a, 'b) t -> 'a -> 'b list
Return all the objects bound to the given key, or raise Not_found:
val lookup : ('a, 'b) t -> 'a -> 'b list
Return all the objects bound to the given key, or the empty list if no binding is found:
val mem : ('a, 'b) t -> 'a -> 'b -> bool
The member predicate.
val memq : ('a, 'b) t -> 'a -> 'b -> bool
The member predicate with the physical equality.
val bound : ('a, 'b) t -> 'a -> bool
Answer if x is bound in the multi map.
val add : ('a, 'b) t -> 'a -> 'b -> unit
Add a binding to the hashmmap.
val add_list : ('a, 'b) t -> ('a * 'b) list -> unit
Add all the binding from the given alist to the map.
val replace : ('a, 'b) t -> 'a -> 'b -> unit
replace h x y
removes all bindings in h
for the key x
, then add the binding (x,y)
.
val remove : ('a, 'b) t -> ?all:bool -> 'a -> unit
Remove one or all (default) bindings of the given key.
val update : ?replace:bool -> ('a, 'b) t -> ('a, 'b) t -> unit
update ~replace t1 t2
updates the map t1
adding (by calling add
) all the bindings from t2
.
If the flag replace
is true
, all existing keys in t2
are removed from t1
before
insertions take place.
val to_list : ('a, 'b) t -> ('a * 'b) list
Make an alist from an hashmmap, returning the bindings as <key, value> pairs in some
unspecified order.
val of_list : ?size:int -> ('a * 'b) list -> ('a, 'b) t
Make a new hashmmap from an alist made of <key, value> pairs.