Documentation
¶
Overview ¶
Package trie implements a prefix tree (trie) data structure.
Index ¶
- type Trie
- func (t *Trie) Add(word string)
- func (t *Trie) Has(word string) bool
- func (t *Trie) HasPrefix(prefix string) bool
- func (t *Trie) Remove(word string) bool
- func (t *Trie) Search(prefix string, limit int) []string
- func (t *Trie) SearchAppend(dst []string, prefix string, limit int) []string
- func (t *Trie) String() string
- func (t *Trie) Stringify(options *tree.Options) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie represents a prefix tree data structure.
func (*Trie) Remove ¶
Remove deletes a word from the Trie if it exists. It returns true if the word was found and removed, false otherwise.
func (*Trie) Search ¶
Search retrieves words in the Trie that have the specified prefix. It returns up to 'limit' number of words. If limit is 0, it returns all matching words.
func (*Trie) SearchAppend ¶
SearchAppend is similar to Search but appends the results to the provided slice. It returns the updated slice containing the matching words.
Click to show internal directories.
Click to hide internal directories.