A polymorphic hashtbl that uses
Pool to avoid allocation.
This uses the standard linked-chain hashtable algorithm, albeit with links performed
through a pool and hence avoiding
caml_modify (for table manipulation), even when
hashing object keys/values.
This implementation is worth exploring for your application if profiling demonstrates
that garbage collection and the
caml_modify write barrier are a significant part of
your execution time.
[@@deriving sexp_of] but not
[@@deriving sexp] because we want people to
be explicit about the hash and comparison functions used when creating hashtables.
One can use
Hashtbl.Poly.t, which does have
[@@deriving sexp], to use
polymorphic comparison and hashing.
Merge two hashtables.
The result of
merge f h1 h2 has as keys the set of all
k in the
union of the sets of keys of
h2 for which
d(k) is not
h1is to d1, and
h2does not map
h2is to d2, and
h1does not map
k is mapped to a single piece of data x, where
d(k) = Some x.
Returns the list of all data for given hashtable.
filter_inplace t ~f removes all the elements from
t that don't satisfy
replace_all t ~f applies f to all elements in
t, transforming them in place
filter_replace_all combines the effects of
resize t size ensures that
t can hold at least
size entries without resizing
(again), provided that
t has growth enabled. This is useful for sizing global
tables during application initialization, to avoid subsequent, expensive growth
online. See Zero.Immediate.String.resize, for example.
on_grow ~before ~after allows you to connect higher level loggers to the point where
these hashtbls grow.
before is called before the table grows, and
after after it.
This permits you to e.g. measure the time elapsed between the two.
This is only meant for debugging and profiling, e.g. note that once a callback is installed, there is no way to remove it.