Documentation
¶
Index ¶
- type Trie
- func (trie *Trie) FindAllByPrefix(prefix string) []string
- func (trie *Trie) FindAllByPrefixForRecall(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) SearchForRecall(word string) bool
- func (trie *Trie) StartsWith(prefix string) bool
- func (trie *Trie) Traverse()
- func (trie *Trie) TraverseForRecall()
- 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) FindAllByPrefixForRecall ¶ added in v0.1.1
FindAllByPrefixForRecall 召回专用的,通过前缀获取所有的节点
func (Trie) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Trie) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Trie) SearchForRecall ¶ added in v0.1.1
SearchForRecall 召回时查询这个word是否存在
func (*Trie) StartsWith ¶
func (*Trie) TraverseForRecall ¶ added in v0.1.1
func (trie *Trie) TraverseForRecall()
TraverseForRecall 查看所有节点的信息
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 cmap.ConcurrentMap[string, *TrieNode] `json:"children"` // 存储子节点的指针 ChildrenRecall map[string]*TrieNode `json:"children_recall"` }
TrieNode TODO:后面看看能不能把build和recall的过程分开,主要是 cmap.ConcurrentMap[string, *TrieNode] 没法反序列化...
func NewTrieNode ¶
func NewTrieNode() *TrieNode
func ParseTrieNode ¶ added in v0.1.1
ParseTrieNode 解析 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