btree

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BTree

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

BTree is an ordered set items

func New

func New(less func(a, b interface{}) bool) *BTree

New returns a new BTree

func (*BTree) Ascend

func (tr *BTree) Ascend(pivot interface{}, iter func(item interface{}) bool)

Ascend the tree within the range [pivot, last] Pass nil for pivot to scan all item in ascending order Return false to stop iterating

func (*BTree) Delete

func (tr *BTree) Delete(key interface{}) interface{}

Delete a value for a key

func (*BTree) DeleteHint

func (tr *BTree) DeleteHint(key interface{}, hint *PathHint) interface{}

DeleteHint deletes a value for a key using a path hint

func (*BTree) Descend

func (tr *BTree) Descend(pivot interface{}, iter func(item interface{}) bool)

Descend the tree within the range [pivot, first] Pass nil for pivot to scan all item in descending order Return false to stop iterating

func (*BTree) Get

func (tr *BTree) Get(key interface{}) interface{}

Get a value for key

func (*BTree) GetHint

func (tr *BTree) GetHint(key interface{}, hint *PathHint) interface{}

GetHint gets a value for key using a path hint

func (*BTree) Height

func (tr *BTree) Height() int

Height returns the height of the tree. Returns zero if tree has no items.

func (*BTree) Len

func (tr *BTree) Len() int

Len returns the number of items in the tree

func (*BTree) Less

func (tr *BTree) Less(a, b interface{}) bool

Less is a convenience function that performs a comparison of two items using the same "less" function provided to New.

func (*BTree) Load

func (tr *BTree) Load(item interface{}) interface{}

Load is for bulk loading pre-sorted items

func (*BTree) Max

func (tr *BTree) Max() interface{}

Max returns the maximum item in tree. Returns nil if the tree has no items.

func (*BTree) Min

func (tr *BTree) Min() interface{}

Min returns the minimum item in tree. Returns nil if the tree has no items.

func (*BTree) PopMax

func (tr *BTree) PopMax() interface{}

PopMax removes the minimum item in tree and returns it. Returns nil if the tree has no items.

func (*BTree) PopMin

func (tr *BTree) PopMin() interface{}

PopMin removes the minimum item in tree and returns it. Returns nil if the tree has no items.

func (*BTree) Set

func (tr *BTree) Set(item interface{}) (prev interface{})

Set or replace a value for a key

func (*BTree) SetHint

func (tr *BTree) SetHint(item interface{}, hint *PathHint) (prev interface{})

SetHint sets or replace a value for a key using a path hint

func (*BTree) Walk

func (tr *BTree) Walk(iter func(item []interface{}))

Walk iterates over all items in tree, in order. The items param will contain one or more items.

type PathHint

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

PathHint is a utility type used with the *Hint() functions. Hints provide faster operations for clustered keys.

Jump to

Keyboard shortcuts

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