Documentation ¶
Index ¶
Constants ¶
const ( TrieEdge bool = true FailEdge bool = false )
const PrimeRK = 16777619
PrimeRK is the prime base used in Rabin-Karp algorithm.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACAutomaton ¶
type ACAutomaton struct {
// contains filtered or unexported fields
}
func NewACAutomaton ¶
func NewACAutomaton() *ACAutomaton
func (*ACAutomaton) Add ¶
func (ac *ACAutomaton) Add(domain string, t Type)
func (*ACAutomaton) Build ¶
func (ac *ACAutomaton) Build()
func (*ACAutomaton) Match ¶
func (ac *ACAutomaton) Match(s string) bool
type ACAutomatonMatcherGroup ¶
type ACAutomatonMatcherGroup struct {
// contains filtered or unexported fields
}
func NewACAutomatonMatcherGroup ¶
func NewACAutomatonMatcherGroup() *ACAutomatonMatcherGroup
func (*ACAutomatonMatcherGroup) AddFullOrDomainPattern ¶
func (g *ACAutomatonMatcherGroup) AddFullOrDomainPattern(pattern string, t Type)
Add `full` or `domain` pattern to hashmap
func (*ACAutomatonMatcherGroup) AddPattern ¶
func (g *ACAutomatonMatcherGroup) AddPattern(pattern string, t Type) (uint32, error)
func (*ACAutomatonMatcherGroup) Build ¶
func (g *ACAutomatonMatcherGroup) Build()
func (*ACAutomatonMatcherGroup) Match ¶
func (g *ACAutomatonMatcherGroup) Match(pattern string) []uint32
Match implements IndexMatcher.Match.
type DomainMatcherGroup ¶
type DomainMatcherGroup struct {
// contains filtered or unexported fields
}
DomainMatcherGroup is a IndexMatcher for a large set of Domain matchers. Visible for testing only.
func (*DomainMatcherGroup) Add ¶
func (g *DomainMatcherGroup) Add(domain string, value uint32)
func (*DomainMatcherGroup) Match ¶
func (g *DomainMatcherGroup) Match(domain string) []uint32
type FullMatcherGroup ¶
type FullMatcherGroup struct {
// contains filtered or unexported fields
}
func (*FullMatcherGroup) Add ¶
func (g *FullMatcherGroup) Add(domain string, value uint32)
func (*FullMatcherGroup) Match ¶
func (g *FullMatcherGroup) Match(str string) []uint32
type IndexMatcher ¶
type IndexMatcher interface { // Match returns the index of a matcher that matches the input. It returns empty array if no such matcher exists. Match(input string) []uint32 }
IndexMatcher is the interface for matching with a group of matchers.
type Matcher ¶
type Matcher interface { // Match returns true if the given string matches a predefined pattern. Match(string) bool String() string }
Matcher is the interface to determine a string matches a pattern.
type MatcherGroup ¶
type MatcherGroup struct {
// contains filtered or unexported fields
}
MatcherGroup is an implementation of IndexMatcher. Empty initialization works.
func (*MatcherGroup) Add ¶
func (g *MatcherGroup) Add(m Matcher) uint32
Add adds a new Matcher into the MatcherGroup, and returns its index. The index will never be 0.
func (*MatcherGroup) Match ¶
func (g *MatcherGroup) Match(pattern string) []uint32
Match implements IndexMatcher.Match.
func (*MatcherGroup) Size ¶
func (g *MatcherGroup) Size() uint32
Size returns the number of matchers in the MatcherGroup.
type Type ¶
type Type byte
Type is the type of the matcher.
const ( // Full is the type of matcher that the input string must exactly equal to the pattern. Full Type = iota // Substr is the type of matcher that the input string must contain the pattern as a sub-string. Substr // Domain is the type of matcher that the input string must be a sub-domain or itself of the pattern. Domain // Regex is the type of matcher that the input string must matches the regular-expression pattern. Regex )