Documentation ¶
Overview ¶
Package btree implements a B-tree.
According to Knuth's definition, a B-tree of order m is a tree which satisfies the following properties: https://en.wikipedia.org/wiki/B-tree
1. Every node has at most m children.
2. Every non-leaf node (except root) has at least ⌈m/2⌉ child nodes.
3. The root has at least two children if it is not a leaf node.
4. A non-leaf node with k children contains k − 1 keys.
5. All leaves appear in the same level and carry no information.
Index ¶
- type Int
- type Item
- type Iterator
- type Node
- type String
- type Tree
- func (t *Tree) Clear()
- func (t *Tree) Delete(item Item)
- func (t *Tree) Insert(item Item)
- func (t *Tree) Length() int
- func (t *Tree) Max() *Node
- func (t *Tree) MaxItems() int
- func (t *Tree) Min() *Node
- func (t *Tree) MinItems() int
- func (t *Tree) Root() *Node
- func (t *Tree) Search(item Item) Item
- func (t *Tree) SearchIterator(item Item) *Iterator
- func (t *Tree) SearchNode(item Item) *Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item interface { // Less compares whether the current item is less than the given Item. Less(than Item) bool }
Item represents a value in the tree.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator represents an iterator in the B-tree.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a node in the B-tree.
func (*Node) MaxIterator ¶
MaxIterator returns the iterator with the max item index of this node.
func (*Node) MinIterator ¶
MinIterator returns the iterator with the min item index of this node.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree represents a B-tree.
func (*Tree) MinItems ¶
MinItems returns the min number of items to allow per node (ignored for the root node).
func (*Tree) SearchIterator ¶
SearchIterator searches the iterator of the B-tree with the item.
func (*Tree) SearchNode ¶
SearchNode searches the node of the B-tree with the item.