Documentation ¶
Index ¶
- type Node
- type RuneFinder
- type Trie
- func (t *Trie[V]) Find(key string) (value V, found bool)
- func (t *Trie[V]) Insert(key string, value V) error
- func (t *Trie[V]) MustInsert(key string, value V) *Trie[V]
- func (t *Trie[V]) Next(r rune) RuneFinder[V]
- func (t *Trie[V]) SubstrMatches(text string) (values []V)
- func (t *Trie[V]) Value() (V, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node[V any] struct { // contains filtered or unexported fields }
Node is a node in the Trie.
func (*Node[V]) Next ¶
func (n *Node[V]) Next(r rune) RuneFinder[V]
type RuneFinder ¶
type RuneFinder[V any] interface { // Next returns the next node in the tree for the given rune // or nil if no such node exists. Next(r rune) RuneFinder[V] // Value returns the value stored at this node. Value() (value V, found bool) }
type Trie ¶
type Trie[V any] struct { // contains filtered or unexported fields }
Trie is a tree data structure that stores strings against values.
The trie (prefix tree) allows for character by character lookup of a string.
func (*Trie[V]) Find ¶
Find returns the value for the given key, or false if the key does not exist.
func (*Trie[V]) Insert ¶
Insert inserts a new key/value pair into the Trie.
It returns an error if the key already exists.
func (*Trie[V]) MustInsert ¶
MustInsert inserts a new key/value pair into the Trie, however unlike [Insert], it panics if the key already exists.
func (*Trie[V]) Next ¶
func (t *Trie[V]) Next(r rune) RuneFinder[V]
func (*Trie[V]) SubstrMatches ¶
SubstrMatches returns all the matches within the given text in the order that they where found.
If there are multiple overlapping matches, all will be returned.
Click to show internal directories.
Click to hide internal directories.