Documentation
¶
Overview ¶
Package prefixtree provides a basic prefix tree implementation.
Add, Has, HasPrefix, Delete and DeletePrefix are linear in query length, regardless of the size of the tree. All operations are non-recursive.
Index ¶
- type Tree
- func (t *Tree) Add(x []byte)
- func (t *Tree) Delete(x []byte) bool
- func (t *Tree) DeletePrefix(x []byte)
- func (t *Tree) FindPrefixes(x []byte) [][]byte
- func (t *Tree) Has(x []byte) bool
- func (t *Tree) HasPrefix(x []byte) bool
- func (t *Tree) Iter() iter.Seq[[]byte]
- func (t *Tree) IterPrefix(x []byte) iter.Seq[[]byte]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
A Tree is a prefix tree.
A zero value tree is invalid; use New to create a new instance.
func (*Tree) Delete ¶
Delete removes x from the tree, if possible. Returns the result of Has(a) before deletion.
func (*Tree) DeletePrefix ¶
DeletePrefix removes prefix x from the tree. All sequences that have x as their prefix are removed. Other sequences are unchanged.
func (*Tree) FindPrefixes ¶
FindPrefixes returns all the elements in the tree that are prefixes of x, ordered by length.
Click to show internal directories.
Click to hide internal directories.