Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = &Options{
MinFillPercent: 0.5,
MaxFillPercent: 0.95,
}
Functions ¶
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func (*Collection) Find ¶
func (c *Collection) Find(key []byte) (*Item, error)
Find Returns an item according based on the given key by performing a binary search.
func (*Collection) ID ¶
func (c *Collection) ID() uint64
func (*Collection) Put ¶
func (c *Collection) Put(key []byte, value []byte) error
Put adds a key to the tree. It finds the correct node and the insertion index and adds the item. When performing the search, the ancestors are returned as well. This way we can iterate over them to check which nodes were modified and rebalance by splitting them accordingly. If the root has too many items, then a new root of a new layer is created and the created nodes from the split are added as children.
func (*Collection) Remove ¶
func (c *Collection) Remove(key []byte) error
Remove removes a key from the tree. It finds the correct node and the index to remove the item from and removes it. When performing the search, the ancestors are returned as well. This way we can iterate over them to check which nodes were modified and rebalance by rotating or merging the unbalanced nodes. Rotation is done first. If the siblings don't have enough items, then merging occurs. If the root is without items after a split, then the root is removed and the tree is one level shorter.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func NewEmptyNode ¶
func NewEmptyNode() *Node
func NewNodeForSerialization ¶
NewNodeForSerialization creates a new node only with the properties that are relevant when saving to the disk