Library
Module
Module type
Parameter
Class
Class type
Output signature of the Make
module.
val empty : 'a t
The empty table.
val is_empty : 'a t -> bool
Tests whether a table is empty or not.
val cardinal : 'a t -> int
Returns the number of bindings of a table.
val length : 'a t -> int
alias of cardinal
alter k f t
adds, modifies or deletes the binding from the key k
in t
, returning the new table. If such a binding exists in t
to a value v
, f
is given Some v
, otherwise None
. The presence of the binding from k
in the result is determined the same way by f
.
Adds a binding to a map, returning the new map. If the binding already existed, the older one disappears.
add_carry k v t
adds a binding to t
, returning the new table and optionnally the value previously bound to k
.
extract
, update
and modify
raise Not_found
if the corresponding binding is not present in their table parameter.
extract k t
removes the binding with the key k
from t
, returning the value previously bound from k
and the new table.
update k f t
updates the binding from k
in t
, optionnally deleting it, and returns the new table.
modify k f t
modifies the binding from k
in t
, and returns the new table.
modify_def v0 k f t
modifies the binding from k
in t
. If no value is bound from k
, the default one v0
is used by f
.
find k t
returns the value bound from the key k
in t
. If there is no such binding, Not_found
is raised.
Returns a binding from a table, which one is unspecified. If the table is Empty
, raises Not_found
.
Removes a binding from a table, returning a pair constituted of this binding and the table without it. If the table is Empty
, raises Not_found
.
val values : 'a t -> 'a list
Returns the list of the values of a table (order unspecified).
Returns the list of the bindings (key, value)
of a table (order unspecified).
Iterates the application of a function over the bindings of a table.
map f t
returns the table with the same keys as t
, where all value v
in t
has been replaced by f v
.
mapi f t
returns the table with the same keys as t
, where all value v
of t
bound from the key k
has been replaced by f k v
.
filterv f t
returns a table whose bindings are the bindings of t
to a value v
where f v = true
.
filter f t
returns a table whose bindings are the bindings of t from a key k
to a value v
where f k v = true
.
Combines the features of filter
and map
. filter_map f t
returns a table where there is a binding from a key k
to a value v
if and only if there is a binding from k
to a value w
in t
where f k w = Some v
.
val foldv : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
fold f t x
computes (f vN ... (f v1 (f v0 x)))
where v0,
v1, ..., vN
are the values bound in t
, provided in unspecified order.
fold f t x
computes (f kN vN ... (f k1 v1 (f k0 v0 x)))
where k0, k1, ..., kN
are the keys of t
and v0, v1, ...,
vN
the values associated to these keys. The order in which the bindings are provided to f
is unspecified.
for_all f t
returns true
if f k v
is true
for all binding from k
to v
in t
, false
otherwise.
exists f t
returns true
if f k v
is true
for at least one binding from k
to v
in t
, false
otherwise.
partition f t
returns a pair (t1, t2)
where t1
is composed of the bindings of t
satisfying the predicate f
, and t2
of the bindings which do not.
intersecti f t1 t2
returns a table with bindings only from keys k
found in t1
and t2
, and to values v = f k v1 v2
if k
is bound to v1
in t1
and to v2
in t2
.
intersecti f t1 t2
returns a table with bindings only from keys k
found in t1
and t2
, and to values v = f v1 v2
if k
is bound to v1
in t1
and to v2
in t2
.
merge f t1 t2
returns a table whose keys is a subset of the keys of t1
and t2
. The presence in the result of each such binding, and its corresponding value, are determined by the function f
.
union t1 t2
returns a table whose keys are all keys presents in t1
or in t2
. If the key is present in both tables, the corresponding value is the one bound in t2
.
union_f f t1 t2
returns a table whose keys are all keys presents in t1
or in t2
. If a key k
is present in only one table, the corresponding value is chosen in the result. If it is bound to v1
in t1
and v2
in t2
, the value in the result is f k v1 v2
.
The Import
module is used to transform a full big set of data into a Hamt. It uses internal mechanisms relying on the implementation of the Hamt structure to provide faster imports than adding the bindings of the imported structure element by element. However, if you want to import a data structure into a Hamt which is already a lot bigger, you should consider adding the elements with the usual fonctions of Make
. At which size difference the faster method is switched is not yet determined and must be analysed in your own case.
module Import : sig ... end
module ExceptionLess : sig ... end
Operations without exceptions.
module Infix : sig ... end
Infix operations.