stree

package
v2.0.0-...-6e60898 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SubjectTree

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

SubjectTree is an adaptive radix trie (ART) for storing subject information on literal subjects. Will use dynamic nodes, path compression and lazy expansion. The reason this exists is to not only save some memory in our filestore but to greatly optimize matching a wildcard subject to certain members, e.g. consumer NumPending calculations.

func NewSubjectTree

func NewSubjectTree[T any]() *SubjectTree[T]

NewSubjectTree creates a new SubjectTree with values T.

func (*SubjectTree[T]) Delete

func (t *SubjectTree[T]) Delete(subject []byte) (*T, bool)

Delete will delete the item and return its value, or not found if it did not exist.

func (*SubjectTree[T]) Dump

func (t *SubjectTree[T]) Dump(w io.Writer)

For dumping out a text representation of a tree.

func (*SubjectTree[T]) Empty

func (t *SubjectTree[T]) Empty() *SubjectTree[T]

Will empty out the tree, or if tree is nil create a new one.

func (*SubjectTree[T]) Find

func (t *SubjectTree[T]) Find(subject []byte) (*T, bool)

Find will find the value and return it or false if it was not found.

func (*SubjectTree[T]) Insert

func (t *SubjectTree[T]) Insert(subject []byte, value T) (*T, bool)

Insert a value into the tree. Will return if the value was updated and if so the old value.

func (*SubjectTree[T]) Iter

func (t *SubjectTree[T]) Iter(cb func(subject []byte, val *T) bool)

Iter will walk all entries in the SubjectTree lexographically. The callback can return false to terminate the walk.

func (*SubjectTree[T]) Match

func (t *SubjectTree[T]) Match(filter []byte, cb func(subject []byte, val *T))

Match will match against a subject that can have wildcards and invoke the callback func for each matched value.

func (*SubjectTree[T]) Size

func (t *SubjectTree[T]) Size() int

Size returns the number of elements stored.

Jump to

Keyboard shortcuts

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