regexpmap

package
v1.6.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 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 RegexpList added in v1.6.0

type RegexpList []string

RegexpList is a utility struct that keeps an array of strings sorted by length

func NewRegexpList added in v1.6.0

func NewRegexpList(initialValues ...string) (result *RegexpList)

NewRegexpList returns a new RegexpList, if any initialValues is in place will add into the utility.

func (*RegexpList) Add added in v1.6.0

func (r *RegexpList) Add(val string)

Add function adds a new item in the list and sort the data based on the length

func (*RegexpList) Get added in v1.6.0

func (r *RegexpList) Get() []string

Get return an array of strings ordered by string len

func (*RegexpList) Len added in v1.6.0

func (r *RegexpList) Len() int

Len returns the len of the internal array.

func (*RegexpList) Remove added in v1.6.0

func (r *RegexpList) Remove(val string)

Remove removes the item from the internal array and keep the data sorted

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 a Regular expression to a lookupValue that will be used in the lookup functions. It will return an error and data will be not saved if the regexp does not compile correctly

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