Removing the least and the greatest entry of a B+-tree #
eraseMinM and eraseMaxM find the least or the greatest entry of a B+-tree of
Cslib.DataStructure.BPlusTree with minM or maxM and then erase its key with eraseM, as
the classic Cslib.DataStructure.BTree.eraseMinM does. Each is defined once over an arbitrary
monad, with a comparator and a node-visit action; eraseMin? and eraseMax? are the Id
instantiations. The tree is walked twice, once to find the entry and once to erase it. Costs are
not stated here.
Main definitions #
eraseMinM,eraseMaxM: removal of the least and the greatest entry, polymorphic.eraseMin?,eraseMax?: the pure operations.
Main results #
map_eraseMinM,map_eraseMaxM: a monad morphism commutes with the removals.eraseMin?_eq,eraseMax?_eq: on a well-formed tree, the first or the last entry together with the tree with its key erased.eraseMin?_eq_some_iff,eraseMax?_eq_some_iff: when an entry and a tree are returned.toList_of_eraseMin?_eq_some,toList_of_eraseMax?_eq_some: the returned tree has the entries after the first, or before the last.IsWF.of_eraseMin?_eq_some,IsWF.of_eraseMax?_eq_some: the returned tree is well-formed.
References #
The statements here are not taken from a source.
A monad morphism commutes with the removal of the least entry.
A monad morphism commutes with the removal of the greatest entry.
Remove and return the least entry, pure.
Remove and return the greatest entry, pure.
Model equation of eraseMin? on well-formed trees: the first entry and the tree with its key
erased.
Model equation of eraseMax? on well-formed trees: the last entry and the tree with its key
erased.
On a well-formed tree, eraseMin? returns p and tr' exactly when p is the first entry
and tr' the tree with its key erased.
On a well-formed tree, eraseMax? returns p and tr' exactly when p is the last entry
and tr' the tree with its key erased.
On a well-formed tree, the tree that eraseMin? returns has the entries after the first.
On a well-formed tree, the tree that eraseMax? returns has the entries before the last.