Documentation
¶
Index ¶
- type Tree
- func (t *Tree[T]) Delete(s string) (removed T, hasRemoved bool)
- func (t *Tree[T]) DeletePrefix(s string) int
- func (t *Tree[T]) Get(s string) (val T, found bool)
- func (t *Tree[T]) Insert(s string, v T) (old T, updated bool)
- func (t *Tree[T]) Len() int
- func (t *Tree[T]) LongestPrefix(s string) (pref string, val T, found bool)
- func (t *Tree[T]) Maximum() (key string, val T, found bool)
- func (t *Tree[T]) Minimum() (key string, val T, found bool)
- func (t *Tree[T]) ToMap() map[string]T
- func (t *Tree[T]) Walk() iter.Seq2[string, T]
- func (t *Tree[T]) WalkPath(path string) iter.Seq2[string, T]
- func (t *Tree[T]) WalkPrefix(prefix string) iter.Seq2[string, T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree[T any] 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,
func NewFromMap ¶
NewFromMap returns a new tree containing the keys from an existing map
func (*Tree[T]) Delete ¶
Delete is used to delete a key, returning the previous value and if it was deleted
func (*Tree[T]) DeletePrefix ¶
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[T]) Insert ¶
Insert is used to add a newentry or update an existing entry. Returns true if an existing record is updated.
func (*Tree[T]) LongestPrefix ¶
LongestPrefix is like Get, but instead of an exact match, it will return the longest prefix match.