trie

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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 NewTrie

func NewTrie() *Trie

func (*Trie) FindAllByPrefix

func (trie *Trie) FindAllByPrefix(prefix string) []string

func (*Trie) Insert

func (trie *Trie) Insert(word string)

func (Trie) MarshalEasyJSON

func (v Trie) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Trie) MarshalJSON

func (v Trie) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Trie) Merge

func (trie *Trie) Merge(other *Trie)

func (*Trie) Search

func (trie *Trie) Search(word string) bool

func (*Trie) StartsWith

func (trie *Trie) StartsWith(prefix string) bool

func (*Trie) Traverse

func (trie *Trie) Traverse()

func (*Trie) UnmarshalEasyJSON

func (v *Trie) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Trie) UnmarshalJSON

func (v *Trie) UnmarshalJSON(data []byte) error

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

func (v TrieNode) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (TrieNode) MarshalJSON

func (v TrieNode) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*TrieNode) UnmarshalEasyJSON

func (v *TrieNode) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*TrieNode) UnmarshalJSON

func (v *TrieNode) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL