memory

package
v0.0.0-...-fc425af Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const M = 4 //128

Variables

This section is empty.

Functions

This section is empty.

Types

type BPTree

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

BPTree represents the root of a b+tree the only thing needed to start a new tree is to simply call bpt := new(BPTree)

func NewBPTree

func NewBPTree() (*BPTree, error)

NewBPTree initializes a new tree

func (*BPTree) Add

func (t *BPTree) Add(k keyType, v valType)

Add inserts a new record using the provided key. It only inserts an record if the key does not already exist.

func (*BPTree) Close

func (t *BPTree) Close()

Close closes the tree

func (*BPTree) Del

func (t *BPTree) Del(k keyType) (keyType, valType)

Del removes the record for the supplied key and attempts to return the previous key and value

func (*BPTree) Get

func (t *BPTree) Get(k keyType) (keyType, valType)

Get returns the record for a given key if it exists

func (*BPTree) GetClosest

func (t *BPTree) GetClosest(k keyType) (keyType, valType)

GetClosest attempts to return the closest match in the tree if an explicit match cannot be found

func (*BPTree) Has

func (t *BPTree) Has(k keyType) bool

Has returns a boolean indicating weather or not the provided key and associated record exists.

func (*BPTree) Len

func (t *BPTree) Len() int

Len returns the a count of the number of items in the tree

func (*BPTree) Max

func (t *BPTree) Max() (keyType, valType)

Max returns the maximum (highest) key and value pair in the tree

func (*BPTree) Min

func (t *BPTree) Min() (keyType, valType)

Min returns the minimum (lowest) key and value pair in the tree

func (*BPTree) Put

func (t *BPTree) Put(k keyType, v valType) bool

Put is mainly used when you wish to upsert as it assumes the data to already be contained the tree. It will overwrite duplicate keys, as it does not check to see if the key exists

func (*BPTree) Range

func (t *BPTree) Range(iter func(k keyType, v valType) bool)

Range provides a simple iteration function for the tree

func (*BPTree) Size

func (t *BPTree) Size() int64

Size attempts to return the tree size in bytes

Jump to

Keyboard shortcuts

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