An efficient implementation of Prof. Arne Andersson's General Balanced Trees. These have no storage overhead compared to unbalanced binary trees, and their performance is in general better than AVL trees.
This module considers two keys as different if and only if
they do not compare equal (
Data structure:
- {Size, Tree}, where `Tree' is composed of nodes of the form:
- {Key, Value, Smaller, Bigger}, and the "empty tree" node:
- nil.
There is no attempt to balance trees after deletions. Since deletions do not increase the height of a tree, this should be OK.
Original balance condition h(T) <= ceil(c * log(|T|)) has been changed to the similar (but not quite equivalent) condition 2 ^ h(T) <= |T| ^ c. This should also be OK.
Performance is comparable to the AVL trees in the Erlang book (and faster in general due to less overhead); the difference is that deletion works for these trees, but not for the book's trees. Behaviour is logarithmic (as it should be).
A GB tree.
A GB tree iterator.
Rebalances
Removes the node with key
Removes the node with key
Returns a new empty tree
Inserts
Turns an ordered list
Retrieves the value stored with
Inserts
Returns
Returns
Returns an iterator that can be used for traversing the
entries of
Returns an iterator that can be used for traversing the
entries of
Returns the keys in
Returns
Looks up
Maps the function F(
Returns
Returns the number of nodes in
Returns
Returns
Returns
Converts a tree into an ordered list of key-value tuples.
Updates
Returns the values in