Documentation ¶
Overview ¶
Package btree provides an implementation of a B-tree. A B-tree is a logarithmic search tree that maintains key-value pairs in sorted order. It is not binary because it stores more than 2 data entries per node. The branching factor for this tree is 64.
Example ¶
package main import ( "fmt" g "github.com/fufuok/utils/generic" "github.com/fufuok/utils/generic/btree" ) func main() { tree := btree.New[int, string](g.Less[int]) tree.Put(42, "foo") tree.Put(-10, "bar") tree.Put(0, "baz") tree.Each(func(key int, val string) { fmt.Println(key, val) }) }
Output: -10 bar 0 baz 42 foo
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree[K, V any] struct { // contains filtered or unexported fields }
Tree implements a B-tree.
func (*Tree[K, V]) Each ¶
func (t *Tree[K, V]) Each(fn func(key K, val V))
Each calls 'fn' on every node in the tree in order.
Click to show internal directories.
Click to hide internal directories.