Documentation ¶
Overview ¶
Package da implements the double array library.
Index ¶
- type DoubleArray
- func (d DoubleArray) CommonPrefixSearch(input string) (ids, lens []int)
- func (d DoubleArray) CommonPrefixSearchCallback(input string, callback func(id, l int))
- func (d DoubleArray) Find(input string) (id int, ok bool)
- func (d DoubleArray) PrefixSearch(input string) (id int, ok bool)
- func (d DoubleArray) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DoubleArray ¶
type DoubleArray []struct { Base, Check int32 }
DoubleArray represents the TRIE data structure.
func Build ¶
func Build(keywords []string) (DoubleArray, error)
Build constructs a double array from given keywords.
func BuildWithIDs ¶
func BuildWithIDs(keywords []string, ids []int) (DoubleArray, error)
BuildWithIDs constructs a double array from given keywords and ids.
func (DoubleArray) CommonPrefixSearch ¶
func (d DoubleArray) CommonPrefixSearch(input string) (ids, lens []int)
CommonPrefixSearch finds keywords sharing common prefix in an input and returns the ids and it's lengths if found.
func (DoubleArray) CommonPrefixSearchCallback ¶
func (d DoubleArray) CommonPrefixSearchCallback(input string, callback func(id, l int))
CommonPrefixSearchCallback finds keywords sharing common prefix in an input and callback with id and length.
func (DoubleArray) Find ¶
func (d DoubleArray) Find(input string) (id int, ok bool)
Find searches TRIE by a given keyword and returns the id if found.
func (DoubleArray) PrefixSearch ¶
func (d DoubleArray) PrefixSearch(input string) (id int, ok bool)
PrefixSearch returns the longest common prefix keyword in an input if found.
Click to show internal directories.
Click to hide internal directories.