memory

package
v0.0.0-...-a89114e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var INVALID_DATA_ERROR = errors.New("Invalid data")
View Source
var INVALID_KEY_ERROR = errors.New("Invalid key")
View Source
var INVALID_KEY_INDEX_ERROR = errors.New("Invalid key index")
View Source
var INVALID_KEY_SIZE_ERROR = errors.New("Invalid key size. All keys must have the same length")
View Source
var INVALID_POINTER_INDEX_ERROR = errors.New("Invalid pointer index")
View Source
var KEY_ALREADY_EXISTS_ERROR = errors.New("Key already exists")
View Source
var KEY_NOT_FOUND_ERROR = errors.New("Key not found")
View Source
var KEY_SIZE_TOO_LARGE = errors.New("The key size is too large.")
View Source
var TYPE_CONVERSION_ERROR = errors.New("Error while converting interface to type")

Functions

This section is empty.

Types

type BTree

type BTree struct {
	// contains filtered or unexported fields
}

func NewTree

func NewTree() *BTree

Returns a pointer to a new in-memory B+ tree

func (*BTree) Delete

func (t *BTree) Delete(key []byte) error

Delete an entry from the tree with the given `key`

func (*BTree) Find

func (t *BTree) Find(key []byte) ([]byte, error)

Find the value associated with a key

func (*BTree) Insert

func (t *BTree) Insert(key, value []byte) error

Insert a new key/value into the tree

func (*BTree) Print

func (t *BTree) Print(withPointers bool) error

Print the tree

func (*BTree) PrintLeaves

func (t *BTree) PrintLeaves() error

Print the leaves of the tree

func (*BTree) PrintLeavesBackwards

func (t *BTree) PrintLeavesBackwards() error

Print the leaves of the tree in reverse, i.e. starting from the end to the beginning

func (*BTree) Update

func (t *BTree) Update(key, newValue []byte) error

Update the value of an existing key in the tree

type BTreeNode

type BTreeNode struct {
	Keys     [][]byte
	Numkeys  int
	Pointers []interface{}
	IsLeaf   bool
	Parent   *BTreeNode
	Next     *BTreeNode
	Prev     *BTreeNode
}

type Record

type Record struct {
	Value []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL