regexpmap

package
v1.5.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RegexpMap

type RegexpMap struct {
	// contains filtered or unexported fields
}

RegexpMap is a map-like type that allows lookups to match regexp keys. These keys are managed internally as strings, and are uniqued by this representation (and not recompiled on repeat inserts). Stored values are strings and are returned as-is, with the exception that repeat inserts of the same value are de-duped. Note: RegexpMap is not thread-safe and managing concurrent access is the responsibility of the callers.

func NewRegexpMap

func NewRegexpMap() *RegexpMap

NewRegexpMap returns an initialized RegexpMap

func (*RegexpMap) Add

func (m *RegexpMap) Add(reStr string, lookupValue string) error

Add associates lookupValue as a return value for reStr on lookup Repeated calls with the same reStr will not recompile the regexp, but will store all lookupValues in a set

func (*RegexpMap) GetPrecompiledRegexp

func (m *RegexpMap) GetPrecompiledRegexp(reStr string) (re *regexp.Regexp)

GetPrecompiledRegexp returns the regexp matching reStr if it is in the map. This is a utility function to avoid recompiling regexps repeatedly, and the RegexpMap keeps the refcount for us.

func (*RegexpMap) LookupContainsValue

func (m *RegexpMap) LookupContainsValue(lookupKey, expectedValue string) (found bool)

LookupContainsValue returns true if any reStr in lookups, inserted via Add, matches lookupKey AND has a lookupValue, inserted via the same Add, that matches expectedValue.

func (*RegexpMap) LookupValues

func (m *RegexpMap) LookupValues(lookupKey string) (lookupValues []string)

LookupValues returns all lookupValues, inserted via Add, where the reStr matches lookupKey

func (*RegexpMap) Remove

func (m *RegexpMap) Remove(reStr, lookupValue string) (deleted bool)

Remove dissociates lookupValue from Lookups that match reStr. When no lookupValues remain for reStr the internall regexp is deleted (later Adds will recompile it).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL