btree

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 1 Imported by: 249

README

B-tree for Go

Travis CI Build Status GoDoc

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 added in v0.2.0

func (tr *BTree) DeleteHint(key interface{}, hint *uint64) 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 added in v0.2.0

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

GetHint gets a value for key using a path hint

func (*BTree) Height added in v0.2.0

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) Load added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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

Set or replace a value for a key

func (*BTree) SetHint added in v0.2.0

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

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

func (*BTree) Walk added in v0.2.0

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.

Jump to

Keyboard shortcuts

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