Legend:
Library
Module
Module type
Parameter
Class
Class type
Memory maps. Memory map is an assosiative data structure that maps memory regions to values. Unlike in the Table, memory regions in the Memmap can intersect in an arbitrary ways. This data structure is also known as an Interval Tree.
Memmap is an instance of the Interval_tree with the Memory serving as an interval.
add map mem tag adds a new memory region mem tagged with tag. If the same region was already in the map it will be tagged with the tag again, even if it has had the same tag.
dominators map mem an ordered sequence of all memory regions, containing mem. A memory region (x,y) contains region (p,q), iff p >= x && q <= y, where memory regions are depicted using closed intervals.
intersections map mem an ordered sequence of all memory regions, that intersects with mem. Memory region (x,y) intersects with region (p,q) iff there exists such z that
z >= p || z <= q && z >= x && z <= y.
In other words if there exists such byte that belongs to both memory regions.
filter_map m f creates a new map by applying a function f to each tag. If f returns Some x then this region will be mapped to x in a new map, otherwise it will be dropped.
val filter_mapi : 'at->f:(mem->'a->'b option)->'bt
filter_mapi is like filter_map but use function also accepts would associated memory region
fold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.
fold_until t ~init ~f ~finish is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed. If f never returns Stop _, the final result is computed by finish.
Example:
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3
val min_elt : 'at->compare:('a->'a-> int)->'a option
Returns a minimum (resp maximum) element from the collection using the provided compare function, or None if the collection is empty. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold.
val max_elt : 'at->compare:('a->'a-> int)->'a option
val pp :
(Stdlib.Format.formatter ->'a-> unit)->Stdlib.Format.formatter ->'at->
unit
pp pp_elem constracts a printer for a memmap to the given element.