Documentation ¶
Index ¶
- func Encode(w io.Writer, trie *Trie) error
- func MatchEqual(a, b *Match) bool
- type Match
- type Trie
- type TrieBuilder
- func (tb *TrieBuilder) AddPattern(pattern []byte) *TrieBuilder
- func (tb *TrieBuilder) AddPatterns(patterns [][]byte) *TrieBuilder
- func (tb *TrieBuilder) AddString(pattern string) *TrieBuilder
- func (tb *TrieBuilder) AddStrings(patterns []string) *TrieBuilder
- func (tb *TrieBuilder) Build() *Trie
- func (tb *TrieBuilder) LoadPatterns(path string) error
- func (tb *TrieBuilder) LoadStrings(path string) error
- type WalkFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchEqual ¶
MatchEqual check whether two matches are equal (i.e. at same position, pattern and same pattern).
Types ¶
type Match ¶
type Match struct {
// contains filtered or unexported fields
}
Match represents a matched pattern in the input.
func (*Match) MatchString ¶
MatchString returns the pattern matched as a string.
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie represents a trie of patterns with extra links as per the Aho-Corasick algorithm.
func (*Trie) MatchFirst ¶
MatchFirst is the same as Match, but returns after first successful match.
func (*Trie) MatchFirstString ¶
MatchFirstString is the same as MatchString, but returns after first successful match.
func (*Trie) MatchString ¶
MatchString runs the Aho-Corasick string-search algorithm on a string input.
type TrieBuilder ¶
type TrieBuilder struct {
// contains filtered or unexported fields
}
TrieBuilder is used to build Tries.
func NewTrieBuilder ¶
func NewTrieBuilder() *TrieBuilder
NewTrieBuilder creates and initializes a new TrieBuilder.
func (*TrieBuilder) AddPattern ¶
func (tb *TrieBuilder) AddPattern(pattern []byte) *TrieBuilder
AddPattern adds a byte pattern to the Trie under construction.
func (*TrieBuilder) AddPatterns ¶
func (tb *TrieBuilder) AddPatterns(patterns [][]byte) *TrieBuilder
AddPatterns adds multiple byte patterns to the Trie.
func (*TrieBuilder) AddString ¶
func (tb *TrieBuilder) AddString(pattern string) *TrieBuilder
AddString adds a string pattern to the Trie under construction.
func (*TrieBuilder) AddStrings ¶
func (tb *TrieBuilder) AddStrings(patterns []string) *TrieBuilder
AddStrings add multiple strings to the Trie.
func (*TrieBuilder) LoadPatterns ¶
func (tb *TrieBuilder) LoadPatterns(path string) error
LoadPatterns loads byte patterns from a file. Expects one pattern per line in hexadecimal form.
func (*TrieBuilder) LoadStrings ¶
func (tb *TrieBuilder) LoadStrings(path string) error
LoadStrings loads string patterns from a file. Expects one pattern per line.