trie

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IterFn

type IterFn func(key []byte, uid uint64) error

type Trie

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

Trie is an implementation of Ternary Search Tries to store XID to UID map. It uses Arena to allocate nodes in the trie. It is not thread-safe.

func NewTrie

func NewTrie() *Trie

NewTrie would return back a Trie backed by the provided Arena. Trie would assume ownership of the Arena. Release must be called at the end to release Arena's resources.

func (*Trie) Get

func (t *Trie) Get(key []byte) uint64

Get would return the UID for the key. If the key is not found, it would return 0.

func (*Trie) Iterate

func (t *Trie) Iterate(fn IterFn) error

func (*Trie) IterateWIthPrefix

func (t *Trie) IterateWIthPrefix(prefix []byte, fn IterFn) error

func (*Trie) Put

func (t *Trie) Put(key []byte, uid uint64)

Put would store the UID for the key.

func (*Trie) Release

func (t *Trie) Release()

Release would release the resources used by the Arena.

func (*Trie) Size

func (t *Trie) Size() uint32

Size returns the size of Arena used by this Trie so far.

Jump to

Keyboard shortcuts

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