Documentation ¶
Index ¶
- type SubjectTree
- func (t *SubjectTree[T]) Delete(subject []byte) (*T, bool)
- func (t *SubjectTree[T]) Dump(w io.Writer)
- func (t *SubjectTree[T]) Empty() *SubjectTree[T]
- func (t *SubjectTree[T]) Find(subject []byte) (*T, bool)
- func (t *SubjectTree[T]) Insert(subject []byte, value T) (*T, bool)
- func (t *SubjectTree[T]) Iter(cb func(subject []byte, val *T) bool)
- func (t *SubjectTree[T]) Match(filter []byte, cb func(subject []byte, val *T))
- func (t *SubjectTree[T]) Size() int
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.