matchergroup_full.go 823 B

123456789101112131415161718192021222324252627282930
  1. package strmatcher
  2. // FullMatcherGroup is an implementation of MatcherGroup.
  3. // It uses a hash table to facilitate exact match lookup.
  4. type FullMatcherGroup struct {
  5. matchers map[string][]uint32
  6. }
  7. func NewFullMatcherGroup() *FullMatcherGroup {
  8. return &FullMatcherGroup{
  9. matchers: make(map[string][]uint32),
  10. }
  11. }
  12. // AddFullMatcher implements MatcherGroupForFull.AddFullMatcher.
  13. func (g *FullMatcherGroup) AddFullMatcher(matcher FullMatcher, value uint32) {
  14. domain := matcher.Pattern()
  15. g.matchers[domain] = append(g.matchers[domain], value)
  16. }
  17. // Match implements MatcherGroup.Match.
  18. func (g *FullMatcherGroup) Match(input string) []uint32 {
  19. return g.matchers[input]
  20. }
  21. // MatchAny implements MatcherGroup.Any.
  22. func (g *FullMatcherGroup) MatchAny(input string) bool {
  23. _, found := g.matchers[input]
  24. return found
  25. }