Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Trie ¶
type Trie[V any] struct { // contains filtered or unexported fields }
A trie that maps a string to a value, supports unicode.
func (*Trie[V]) Get ¶
Return the value and the exist indicator.
If the key exists, it returns (value, true).
Otherwise, it returns (zero value, false).
Example ¶
trie := New[int]() trie.Insert("hello, 世界", 123) fmt.Println(trie.Get("hello, world")) fmt.Println(trie.Get("hello, 世界"))
Output: 0 false 123 true
func (*Trie[V]) Insert ¶
Insert a key value pair to the trie.
If the key value pair entry already exists, it updates the value.
Example ¶
trie := New[int]() trie.Insert("hello", 1) trie.Insert("world", 2) trie.Insert("你好", 3) trie.Insert("世界", 4) fmt.Println(trie.Len())
Output: 4
Click to show internal directories.
Click to hide internal directories.