radix

package
v1.7.672 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortUint64s added in v1.6.1

func SortUint64s(x []uint64)

SortUint64s sorts a slice of uint64s.

Types

type Tree

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

Tree implements a radix tree. This can be treated as a Dictionary abstract data type. The main advantage over a standard hash map is prefix-based lookups and ordered iteration. The tree is safe for concurrent access.

func New

func New() *Tree

New returns an empty Tree

func NewFromMap

func NewFromMap(m map[string]int) *Tree

NewFromMap returns a new tree containing the keys from an existing map

func (*Tree) DeletePrefix

func (t *Tree) DeletePrefix(s []byte) int

DeletePrefix is used to delete the subtree under a prefix Returns how many nodes were deleted Use this to delete large subtrees efficiently

func (*Tree) Get

func (t *Tree) Get(s []byte) (int, bool)

Get is used to lookup a specific key, returning the value and if it was found

func (*Tree) Insert

func (t *Tree) Insert(s []byte, v int) (int, bool)

Insert is used to add a newentry or update an existing entry. Returns if inserted.

func (*Tree) Len

func (t *Tree) Len() int

Len is used to return the number of elements in the tree

func (*Tree) Maximum

func (t *Tree) Maximum() ([]byte, int, bool)

Maximum is used to return the maximum value in the tree

func (*Tree) Minimum

func (t *Tree) Minimum() ([]byte, int, bool)

Minimum is used to return the minimum value in the tree

Jump to

Keyboard shortcuts

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