Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

avl source pure

Functions 2

Types 4

type ITree

interface
 1type ITree interface {
 2	Size() int
 3	Has(key string) bool
 4	Get(key string) any
 5	GetByIndex(index int) (key string, value any)
 6	Iterate(start, end string, cb IterCbFn) bool
 7	ReverseIterate(start, end string, cb IterCbFn) bool
 8	IterateByOffset(offset int, count int, cb IterCbFn) bool
 9	ReverseIterateByOffset(offset int, count int, cb IterCbFn) bool
10
11	Set(key string, value any) (updated bool)
12	Remove(key string) (value any, removed bool)
13}
source

type IterCbFn

func
1type IterCbFn func(key string, value any) bool
source

type Node

struct
1type Node struct {
2	key       string // key is the unique identifier for the node.
3	value     any    // value is the data stored in the node.
4	height    int8   // height is the height of the node in the tree.
5	size      int    // size is the number of leaf nodes (key-value pairs) in the subtree rooted at this node.
6	leftNode  *Node  // leftNode is the left child of the node.
7	rightNode *Node  // rightNode is the right child of the node.
8}
source

Methods on Node

func Get

method on Node
1func (node *Node) Get(key string) (index int, value any, exists bool)
source

func GetByIndex

method on Node
1func (node *Node) GetByIndex(index int) (key string, value any)
source

func Has

method on Node
1func (node *Node) Has(key string) (has bool)
source

func IsLeaf

method on Node
1func (node *Node) IsLeaf() bool
source

func Iterate

method on Node
1func (node *Node) Iterate(start, end string, cb func(*Node) bool) bool
source

func Key

method on Node
1func (node *Node) Key() string
source

func Remove

method on Node
1func (node *Node) Remove(key string) (
2	newNode *Node, newKey string, value any, removed bool,
3)
source

func ReverseIterate

method on Node
1func (node *Node) ReverseIterate(start, end string, cb func(*Node) bool) bool
source

func Set

method on Node
1func (node *Node) Set(key string, value any) (newSelf *Node, updated bool)
source

func Size

method on Node
1func (node *Node) Size() int
source

func TraverseByOffset

method on Node
1func (node *Node) TraverseByOffset(offset, limit int, ascending bool, leavesOnly bool, cb func(*Node) bool) bool
source

func TraverseInRange

method on Node
1func (node *Node) TraverseInRange(start, end string, ascending bool, leavesOnly bool, cb func(*Node) bool) bool
source

func Value

method on Node
1func (node *Node) Value() any
source

type Tree

struct
1type Tree struct {
2	node *Node
3}
source

Methods on Tree

func Get

method on Tree
1func (tree *Tree) Get(key string) any
source

func GetByIndex

method on Tree
1func (tree *Tree) GetByIndex(index int) (key string, value any)
source

func Has

method on Tree
1func (tree *Tree) Has(key string) (has bool)
source

func Iterate

method on Tree
1func (tree *Tree) Iterate(start, end string, cb IterCbFn) bool
source

func IterateByOffset

method on Tree
1func (tree *Tree) IterateByOffset(offset int, count int, cb IterCbFn) bool
source

func Remove

method on Tree
1func (tree *Tree) Remove(key string) (value any, removed bool)
source

func ReverseIterate

method on Tree
1func (tree *Tree) ReverseIterate(start, end string, cb IterCbFn) bool
source

func Set

method on Tree
1func (tree *Tree) Set(key string, value any) (updated bool)
source

func Size

method on Tree
1func (tree *Tree) Size() int
source

Source Files 3