Documentation
¶
Index ¶
- func MergeID16(left uint16, leftLength uint8, right uint16, rightLength uint8) (uint16, uint8)
- func MergeID32(left uint32, leftLength uint8, right uint32, rightLength uint8) (uint32, uint8)
- func MergeID64(left uint64, leftLength uint8, right uint64, rightLength uint8) (uint64, uint8)
- type Enries
- type Entries
- type Entry
- type FilterFunc
- type ID
- type IsLeftBitSetFn
- type MatchesFunc
- type Range
- type Tree
- func (r *Tree[T]) Add(id ID, val T, matchFunc MatchesFunc[T]) (bool, int)
- func (r *Tree[T]) Clone() *Tree[T]
- func (r *Tree[T]) Delete(id ID, matchFunc MatchesFunc[T], matchVal T) int
- func (r *Tree[T]) DeleteWithBuffer(buf []T, id ID, matchFunc MatchesFunc[T], matchVal T) int
- func (r *Tree[T]) Iterate() *TreeIterator[T]
- func (r *Tree[T]) PrintNodes(nodeIndex uint)
- func (r *Tree[T]) PrintValues()
- func (r *Tree[T]) Set(id ID, val T) (bool, int)
- type TreeIterator
- type UpdatesFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FilterFunc ¶
FilterFunc[T] is called on each result to see if it belongs in the resulting set
type IsLeftBitSetFn ¶
type MatchesFunc ¶
MatchesFunc[T] is called to check if tag data matches the input value
type Range ¶
type Range interface { From() ID To() ID SetTo(ID) Range SetFrom(ID) Range String() string IsValid() bool IsZero() bool IDs() []ID Less(other Range) bool AppendIDs(dst []ID) []ID EntirelyBefore(other Range) bool CoveredBy(other Range) bool InMiddleOf(other Range) bool OverlapsStartOf(other Range) bool OverlapsEndOf(other Range) bool }
type Tree ¶
type Tree[T any] struct { // contains filtered or unexported fields }
func NewTree ¶
func NewTree[T any](name string, isLeftBitSetFn IsLeftBitSetFn, length uint8) *Tree[T]
func (*Tree[T]) Add ¶
func (r *Tree[T]) Add(id ID, val T, matchFunc MatchesFunc[T]) (bool, int)
Add adds a tag to the tree - if matchFunc is non-nil, it will be used to ensure uniqueness at this node - returns whether the val count at this address was increased, and how many vals at this address
func (*Tree[T]) Clone ¶
Clone creates an identical copy of the tree - Note: the items in the tree are not deep copied
func (*Tree[T]) Delete ¶
func (r *Tree[T]) Delete(id ID, matchFunc MatchesFunc[T], matchVal T) int
Delete a tag from the tree if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - use DeleteWithBuffer if you can reuse slices, to cut down on allocations
func (*Tree[T]) DeleteWithBuffer ¶
func (r *Tree[T]) DeleteWithBuffer(buf []T, id ID, matchFunc MatchesFunc[T], matchVal T) int
DeleteWithBuffer a tag from the tree if it matches matchVal, as determined by matchFunc. Returns how many tags are removed - uses input slice to reduce allocations
func (*Tree[T]) Iterate ¶
func (r *Tree[T]) Iterate() *TreeIterator[T]
Iterate returns an iterator to find all nodes from a tree. It is important for the tree to not be modified while using the iterator.
func (*Tree[T]) PrintNodes ¶
note: this is only used for unit testing nolint
func (*Tree[T]) PrintValues ¶
func (r *Tree[T]) PrintValues()
note: this is only used for unit testing nolint
type TreeIterator ¶
type TreeIterator[T any] struct { // contains filtered or unexported fields }
TreeIteratorV4[T] is a stateful iterator over a tree.
func (*TreeIterator[T]) Next ¶
func (iter *TreeIterator[T]) Next() bool
Next jumps to the next element of a tree. It returns false if there is none.
func (*TreeIterator[T]) Vals ¶
func (iter *TreeIterator[T]) Vals() []T
Tags returns the current tags for the iterator. This is not a copy and the result should not be used outside the iterator.
func (*TreeIterator[T]) ValsWithBuffer ¶
func (iter *TreeIterator[T]) ValsWithBuffer(ret []T) []T
TagsWithBuffer returns the current tags for the iterator. To avoid allocation, it uses the provided buffer.
type UpdatesFunc ¶
type UpdatesFunc[T any] func(payload T) T
UpdatesFunc[T] is called to update the tag value