tree

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 2 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 : wrapped b-tree

func NewBTree

func NewBTree() *BTree

NewBTree : new

func (*BTree) AscendGt

func (b *BTree) AscendGt(k Node, filter FilterFn, n int) []Node

AscendGt : ascend get nodes(>k). k : anchor key filter : filter a node n : the max length of nodes to get

func (*BTree) AscendGte

func (b *BTree) AscendGte(k Node, filter FilterFn, n int) []Node

AscendGte : ascend get nodes(>=k). k : anchor key filter : filter a node n : the max length of nodes to get

func (*BTree) Delete

func (b *BTree) Delete(k Node) bool

Delete : delete node, actually, figure out a node which related node sort fields match. Return : bool If deleted node exist, return true, else return false

func (*BTree) DescendLt

func (b *BTree) DescendLt(k Node, filter FilterFn, n int) []Node

DescendLt : descend get nodes(<k). k : anchor key filter : filter a node n : the max length of nodes to get

func (*BTree) DescendLte

func (b *BTree) DescendLte(k Node, filter FilterFn, n int) []Node

DescendLte : descend get nodes(<=k). k : anchor key filter : filter a node n : the max length of nodes to get

func (*BTree) Get

func (b *BTree) Get(k Node) Node

Get : get node by key

func (*BTree) Insert

func (b *BTree) Insert(v Node)

Insert : insert node to btree

func (*BTree) Update

func (b *BTree) Update(oldV Node, newV Node) bool

Update : update old node to given new node. If old node not exist, the newV could not be updated. Return : if old node not exist, return false, else return true.

func (*BTree) UpdateOrInsert

func (b *BTree) UpdateOrInsert(oldV Node, newV Node) bool

UpdateOrInsert : if ole node exists, update old node to new node, else insert new node to btree. The new node will always be inserted or replaced. Return : bool If ole node not exist, return false, it indicates that ole node not found but new node be inserted. Else return ture.

type FilterFn

type FilterFn func(n Node) bool

FilterFn : filter a node value is in condition or not

type Node added in v0.0.9

type Node = btree.Item

Node : redirect btree.Item

Directories

Path Synopsis
Package btree implements in-memory B-Trees of arbitrary degree.
Package btree implements in-memory B-Trees of arbitrary degree.

Jump to

Keyboard shortcuts

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