Documentation
¶
Index ¶
- type Trie
- func (trie *Trie) FindAllByPrefix(prefix string) []string
- func (trie *Trie) Insert(word string)
- func (v Trie) MarshalEasyJSON(w *jwriter.Writer)
- func (v Trie) MarshalJSON() ([]byte, error)
- func (trie *Trie) Merge(other *Trie)
- func (trie *Trie) Search(word string) bool
- func (trie *Trie) StartsWith(prefix string) bool
- func (trie *Trie) Traverse()
- func (v *Trie) UnmarshalEasyJSON(l *jlexer.Lexer)
- func (v *Trie) UnmarshalJSON(data []byte) error
- type TrieNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Trie ¶
type Trie struct {
Root *TrieNode `json:"root"` // 存储 Trie 树的根节点
}
func (*Trie) FindAllByPrefix ¶
func (Trie) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Trie) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Trie) StartsWith ¶
func (*Trie) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Trie) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type TrieNode ¶
type TrieNode struct {
IsEnd bool `json:"is_end"` // 标记该节点是否为一个单词的末尾
Children map[rune]*TrieNode `json:"children"` // 存储子节点的指针
}
func NewTrieNode ¶
func NewTrieNode() *TrieNode
func (TrieNode) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (TrieNode) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*TrieNode) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*TrieNode) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
Click to show internal directories.
Click to hide internal directories.