tree234

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = logrus.New()

Functions

This section is empty.

Types

type CompareFunc

type CompareFunc[T any] func(x, y *T) int

type Node234

type Node234[T any] struct {
	// contains filtered or unexported fields
}

func (*Node234[T]) ChildIndex

func (n *Node234[T]) ChildIndex() int

func (*Node234[T]) Count

func (n *Node234[T]) Count() (c int)

func (*Node234[T]) KidsCount

func (n *Node234[T]) KidsCount() (c int)

func (*Node234[T]) Size

func (n *Node234[T]) Size() (s int)

func (*Node234[T]) String

func (n *Node234[T]) String() string

type Relation

type Relation uint8
const (
	Eq Relation = iota
	Lt
	Le
	Gt
	Ge
)

type Tree234

type Tree234[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](cmp CompareFunc[T]) *Tree234[T]

func (*Tree234[T]) Add

func (t *Tree234[T]) Add(e *T) *T

func (Tree234[T]) Count

func (t Tree234[T]) Count() int

func (*Tree234[T]) Delete

func (t *Tree234[T]) Delete(e *T) *T

func (*Tree234[T]) DeletePos

func (t *Tree234[T]) DeletePos(index int) *T

func (*Tree234[T]) FindRelPos

func (t *Tree234[T]) FindRelPos(e *T, relation Relation) (el *T, index int)

Find an element e in a sorted 2-3-4 tree t. Returns NULL if not found. e is always passed as the first argument to cmp[, so cmp can be an asymmetric function if desired. cmp can also be passed as NULL, in which case the compare function from the tree proper will be used].

func (*Tree234[T]) Index

func (t *Tree234[T]) Index(index int) *T

Look up the element at a given numeric index in a 2-3-4 tree. Returns NULL if the index is out of range.

func (Tree234[T]) String

func (t Tree234[T]) String() string

Jump to

Keyboard shortcuts

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