Documentation ¶
Overview ¶
Package prefix holds a prefix tree for strings. The term word is used to refer to values which are present in the tree. Gram is used to refer to any sequence that exists in the tree. For instance is the word 'test' is inserted then the tree contains the gram 'tes' but it will not be a word.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node interface { // Child looks up the child node by rune Child(rune) Node // Children returns all the child runes Children() []rune // ChildrenCount returns the number of children ChildrenCount() int // IsWord returns true if this Node was inserted as word into the tree IsWord() bool // Gram returns the string this node represents Gram() string Suggest(max int) []Suggestion // AllWords returns all child nodes (including self) that are a word. AllWords() Nodes }
Node in a prefix tree.
type Prefix ¶
type Prefix struct {
// contains filtered or unexported fields
}
Prefix is the root of a prefix tree
func (*Prefix) Containing ¶
Containing returns all nodes in the tree containing the specified gram, even if they do not begin with the specified gram.
type Suggestion ¶
func (Suggestion) Words ¶
func (s Suggestion) Words(prefix string) []string
Click to show internal directories.
Click to hide internal directories.