trie

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Leaf

type Leaf[T any] struct {
	Path  []string
	Value T
}

type Regex added in v0.1.6

type Regex struct {
	Pattern string
	// contains filtered or unexported fields
}

func NewRegex added in v0.1.6

func NewRegex(pattern string) (*Regex, error)

type Trie

type Trie[T any] struct {
	deadlock.RWMutex
	// contains filtered or unexported fields
}

func New

func New[T any](source interface{}) *Trie[T]

func (*Trie[T]) Clear added in v0.1.11

func (t *Trie[T]) Clear(sequence []interface{})

Clear all mappings in the trie with the prefix `sequence`. An empty sequence will clear all mappings.

func (*Trie[T]) Get

func (t *Trie[T]) Get(sequence []string) (value T, re []string, matched bool)

Get attempts to retrieve the leaf referred to by `sequence`. Any steps traversed using regex matches will be returned in `re` in the order in which they appeared in the sequence.

func (*Trie[T]) Leaves

func (t *Trie[T]) Leaves() (leaves []Leaf[T])

Leaves gets all of the leaves accessible from this Trie and the path to each leaf. Regex paths are represented as "re:[pattern]".

func (*Trie[T]) Partial

func (t *Trie[T]) Partial(sequence []string) (result []Leaf[T])

Get a list of all partial matches for a sequence, if any.

func (*Trie[T]) Remap added in v0.1.11

func (t *Trie[T]) Remap(from, to []interface{})

Remap the subtree at sequence `from` to sequence `to`.

func (*Trie[T]) Set

func (t *Trie[T]) Set(sequence []interface{}, value T)

func (*Trie[T]) Source added in v0.1.11

func (t *Trie[T]) Source() interface{}

Jump to

Keyboard shortcuts

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