Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Data.Range_tree
This module describe "Range trees", a datastructure for symbolic reasoning about a range of data.
Range trees are representation of an array of symbolic size. Each node of the tree represents a contiguous range of the array (a S_range.Make.t using a given type of symbolic integers 'sint). Each node also some data, which must be mergeable.
Each node has either no children, or exactly two children, which represent a split of the node's range into two contiguous subranges, i.e. if the parent node covers a..c (note that it doesn't include "c"), then the children must cover a..b and b..c with a < b < c.
Additionally, we maintain the invariant that the tree is balanced, i.e. for any node, the height of its left and right children can differ by at most 1. This is for obvious performance reasons.
type info
Type describing the information associated to a range tree, such as its height and whether it is balanced. Opaque because it is optimised.
Builds a tree given a node, a range, and children, and automatically balances it.
val rebuild : merge:('a->'a->'a)->('a, 'sint)t->('a, 'sint)t
Rebalances an existing tree bottom-up, using merge to recompute intermediate node values created during rotations.
val offset :
add:('sint->'sint->'sint)->by:'sint->('a, 'sint)t->('a, 'sint)t
offset ~apply_ofs t uses the function apply_ofs on all offset in the ranges of the tree t.
Effectively, this function is just a map_offsets, but applying any other transformation to the offsets of the tree than offsetting by a constant integer is invalid.
val iter_leaves_rev : ('a, 'sint)t->(('a, 'sint)t-> unit)-> unit
iter_leaves_rev t is an iterator over the leaves of the tree t from right to left.
map_leaves M f t receives a mapping function f operating within the monad M, as well as a tree, and applys f to all leaves of the tree (not the inner nodes).