radixtrie

package
v0.17.21 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath          = errors.New("invalid path")
	ErrInvalidHost          = errors.New("invalid host")
	ErrNotFound             = errors.New("not found")
	ErrFailedToDelete       = errors.New("failed to delete")
	ErrConstraintsViolation = errors.New("constraints violation")
)

Functions

This section is empty.

Types

type ConstraintsFunc

type ConstraintsFunc[V any] func(oldValues []V, newValue V) bool

type Entry

type Entry[V any] struct {
	Value      V
	Parameters map[string]string
}

type LookupMatcher

type LookupMatcher[V any] interface {
	// Match should return true if the value should be returned by the lookup.
	Match(value V, keys, values []string) bool
}

LookupMatcher is used for additional checks while performing the lookup of values in the spanned tree.

type LookupMatcherFunc

type LookupMatcherFunc[V any] func(value V, keys, values []string) bool

The LookupMatcherFunc type is an adapter to allow the use of ordinary functions as match functions. If f is a function with the appropriate signature, LookupMatcherFunc(f) is a LookupMatcher that calls f.

func (LookupMatcherFunc[V]) Match

func (f LookupMatcherFunc[V]) Match(value V, keys, values []string) bool

Match calls f(value).

type LookupOption

type LookupOption[V any] func(opts *lookupOpts[V])

func WithExactMatch

func WithExactMatch[V any]() LookupOption[V]

func WithWildcardMatch

func WithWildcardMatch[V any]() LookupOption[V]

type Option

type Option[V any] func(n *Trie[V])

func WithValuesConstraints

func WithValuesConstraints[V any](constraints ConstraintsFunc[V]) Option[V]

type Trie

type Trie[V any] struct {
	// contains filtered or unexported fields
}

func New

func New[V any](opts ...Option[V]) *Trie[V]

func (*Trie[V]) Add

func (t *Trie[V]) Add(hostPattern, pathPattern string, value V) error

func (*Trie[V]) Clone

func (t *Trie[V]) Clone() *Trie[V]

func (*Trie[V]) Delete

func (t *Trie[V]) Delete(hostPattern, pathPattern string, matcher ValueMatcher[V]) error

func (*Trie[V]) Empty

func (t *Trie[V]) Empty() bool

func (*Trie[V]) FindEntry

func (t *Trie[V]) FindEntry(host, path string, matcher LookupMatcher[V]) (*Entry[V], error)

func (*Trie[V]) Lookup

func (t *Trie[V]) Lookup(hostPattern, pathPattern string, opts ...LookupOption[V]) ([]*Trie[V], error)

type ValueMatcher

type ValueMatcher[V any] interface {
	// Match should return true if the value should be deleted from the tree.
	Match(value V) bool
}

ValueMatcher is used for additional checks while deleting of values in the spanned tree.

type ValueMatcherFunc

type ValueMatcherFunc[V any] func(value V) bool

The ValueMatcherFunc type is an adapter to allow the use of ordinary functions as match functions. If f is a function with the appropriate signature, ValueMatcherFunc(f) is a ValueMatcher that calls f.

func (ValueMatcherFunc[V]) Match

func (f ValueMatcherFunc[V]) Match(value V) bool

Match calls f(value).

Jump to

Keyboard shortcuts

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