trie

package
v0.11.2-2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeSegment

func EscapeSegment(seg string) string

Types

type AnyValue

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

AnyValue is a wrapper of atomic.Value It is used to store values in trie nodes And allowed to assign to empty struct value when node is not an end node anymore

func (*AnyValue) IsNil

func (av *AnyValue) IsNil() bool

func (*AnyValue) Load

func (av *AnyValue) Load() any

func (*AnyValue) Store

func (av *AnyValue) Store(v any)

func (*AnyValue) Swap

func (av *AnyValue) Swap(v any) any

type Iterator

type Iterator = func(YieldFunc)

type Key

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

func Namespace

func Namespace(ns string) *Key

func NewKey

func NewKey(keyStr string) *Key

func (*Key) Clone

func (ns *Key) Clone() *Key

func (*Key) HasWildcard

func (ns *Key) HasWildcard() bool

func (*Key) NumSegments

func (ns *Key) NumSegments() int

func (*Key) String

func (ns *Key) String() string

func (Key) With

func (ns Key) With(segment string) *Key

func (Key) WithEscaped

func (ns Key) WithEscaped(segment string) *Key

type KeyIterator

type KeyIterator = func(YieldKeyFunc)

type Node

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

func (*Node) Get

func (node *Node) Get(key *Key) (any, bool)

func (*Node) Keys

func (node *Node) Keys() []string

func (*Node) Map

func (node *Node) Map() map[string]any

func (*Node) Walk

func (node *Node) Walk(yield YieldFunc)

WalkAll walks all nodes in the trie, yields full key and series

func (*Node) WalkKeys

func (node *Node) WalkKeys(yield YieldKeyFunc)

type Root

type Root struct {
	*Node
	// contains filtered or unexported fields
}

func NewTrie

func NewTrie() *Root

func (*Root) LoadAndStore

func (r *Root) LoadAndStore(key *Key, val any) any

LoadAndStore loads or stores the value for the key Returns the old value if exists, nil otherwise

func (*Root) LoadOrStore

func (r *Root) LoadOrStore(key *Key, newFunc func() any) any

LoadOrStore loads or stores the value for the key Returns the value loaded/stored

func (*Root) MarshalJSON

func (r *Root) MarshalJSON() ([]byte, error)

func (Root) Query

func (tree Root) Query(key *Key) Iterator

func (*Root) Store

func (r *Root) Store(key *Key, val any)

Store stores the value for the key

func (*Root) UnmarshalJSON

func (r *Root) UnmarshalJSON(data []byte) error

type YieldFunc

type YieldFunc = func(part string, value any) bool

type YieldKeyFunc

type YieldKeyFunc = func(key string) bool

Jump to

Keyboard shortcuts

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