Documentation ¶
Overview ¶
Package trie implements a simple trie data structure that maps "paths" (which are slices of strings) to values of some type T.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Trie ¶
type Trie[T interface{}] struct {
// contains filtered or unexported fields
}
func (*Trie[T]) Get ¶
Get retrieves an entry from the Trie. If there is no fully-matching entry, Get returns `(nil, false)`. `path` can be empty, to denote the root node.
Example:
if res, ok := trie.Get([]string{"foo", "bar"}); ok { fmt.Println("Value at /foo/bar was", res) }
func (*Trie[T]) GetLongestPrefix ¶
GetLongestPrefix retrieves the longest matching entry from the Trie.
GetLongestPrefix returns a full match if there is one, or the entry with the longest matching prefix. If there is no match at all, GetLongestPrefix returns `(nil, false)`. `path` can be empty, to denote the root node.
Example:
if res, ok := trie.GetLongestPrefix([]string{"foo", "bar"}); ok { fmt.Println("Value at /foo/bar was", res) }
Click to show internal directories.
Click to hide internal directories.