package batteries
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=b691e5870f876c6e590d6aa51b4c5457
sha512=3b0643ff337cd70da8c4b77887d212e82d043a7163fca36588be12186bc86bbcf0d56b13349325f12eabb96c846204c88560786342f50af7bf4e20b9480d3964
doc/batteries.unthreaded/BatIMap/index.html
Module BatIMap
Source
DIET Maps from integers, packed using ranges
The empty map. Needs one parameter: a comparison function for the values, to enable merging of ranges with identical values.
add x y t
adds a binding from x
to y
in t
, returning a new map.
add_range lo hi y t
adds bindings to y
for all values in the range lo,hi
, returning a new map
modify x f t
replaces the y
that is bound to x
in t
by f y
.
modify_def dft x f t
does the same as modify x f t
but binds x
to f dft
if x
was not bound.
modify_opt x f t
allows to modify the binding for x
in t
or absence thereof.
iter_range f t
calls f
on every contiguous range. For maps, contiguous ranges must map to the same y
Create a new map by modifying each y
by the given function. This will not create new ranges; the mapping function is only applied to each contiguous range once. It is not applied to the ranges in order. ~eq
defaults to (=).
Create a new map by computing new values based on key and value of the existing bindings. This can create new ranges, as adjacent bindings can be assigned different values. ~eq
defaults to (=).
Create a new map by modifying each y
using the given function. This will not create new ranges, but will have access to the lo,hi
of the current range. ~eq
defaults to (=).
fold f t x0
folds all the bindings of t
into x0
using f
to merge.
fold_range f t x0
folds all the contiguous ranges of t
into x0
using f
to merge. The order of foldings is unspecified.
set_to_map s x
returns a map where every element of s
is bound to x
.
map_to_set p t
returns the set of keys of t
where p
evaluates as true
enum t
returns an enumeration of the bindings in t
of_enum e
returns the set of given ranges
fold2_range f t u x0
folds across each range that's defined in either t
or u
or both, giving that range and the possible values to f
to merge with x0
.
Example: let union_first = fold2_range (fun _lo _hi a b = match a,b with Some x,_ -> x | _,Some y -> y)