Rank queries in B+-trees #
rankM counts the entries with key strictly below the query by one descent, following the
search of lookupM. Each separator passed contributes the size of the child before it, and the
leaf at the end of the path contributes the rank of the query in its entry list, by the scan
Cslib.SortedAssoc.rankM. The sizes of the children passed are pure subtree sizes: computing
them is uncharged client computation, as in the classic tree. visit fires once at each node on
the path, the leaf included.
Main definitions #
Main results #
Rank by a single descent. Pass the separators that are at most k, adding the pure size of
the child before each; descend into the child introduced by the last of them; in the leaf, scan
the entries. visit fires once at each node on the path.
A monad morphism commutes with the rank query.
Rank in a leaf is the scan of its entries.
Rank at a node's first separator: when it is at most the query, count the child before it and pass it; otherwise descend into that child.
Model equation of rank on well-formed trees.