package doctree
import "github.com/gohugoio/hugo/hugolib/doctree"
Index ¶
- func ValidateKey(key string) error
- type Config
- type Event
- type LockType
- type MutableTree
- type MutableTrees
- func (t MutableTrees) CanLock() bool
- func (t MutableTrees) DeletePrefix(prefix string) int
- func (t MutableTrees) DeletePrefixRaw(prefix string) int
- func (t MutableTrees) DeleteRaw(key string)
- func (t MutableTrees) Lock(writable bool)
- func (t MutableTrees) Unlock(writable bool)
- type NodeShiftTree
- func New[T any](cfg Config[T]) *NodeShiftTree[T]
- func (r *NodeShiftTree[T]) AppendRaw(s string, ts ...T) (T, bool)
- func (t *NodeShiftTree[T]) CanLock() bool
- func (r *NodeShiftTree[T]) Delete(key string) (T, bool)
- func (r *NodeShiftTree[T]) DeleteFuncRaw(key string, f func(T) bool) (T, int)
- func (r *NodeShiftTree[T]) DeletePrefix(prefix string) int
- func (t *NodeShiftTree[T]) DeletePrefixRaw(prefix string) int
- func (r *NodeShiftTree[T]) DeleteRaw(key string)
- func (r *NodeShiftTree[T]) ForEeachInAllDimensions(s string, f func(T) bool)
- func (r *NodeShiftTree[T]) ForEeachInDimension(s string, dims sitesmatrix.Vector, d int, f func(T) bool)
- func (r *NodeShiftTree[T]) Get(s string) T
- func (r *NodeShiftTree[T]) GetRaw(s string) (T, bool)
- func (r *NodeShiftTree[T]) Has(s string) bool
- func (r *NodeShiftTree[T]) Insert(s string, v T) (T, T, bool)
- func (r *NodeShiftTree[T]) InsertRaw(s string, v T) (T, bool)
- func (r *NodeShiftTree[T]) InsertRawWithLock(s string, v T) (T, bool)
- func (r *NodeShiftTree[T]) InsertWithLock(s string, v T) (T, T, bool)
- func (t *NodeShiftTree[T]) Len() int
- func (t *NodeShiftTree[T]) Lock(writable bool)
- func (r *NodeShiftTree[T]) LongestPrefiValueRaw(s string) (string, T)
- func (r *NodeShiftTree[T]) LongestPrefix(s string, fallback bool, predicate func(v T) bool) (string, T)
- func (r *NodeShiftTree[T]) LongestPrefixRaw(s string) (string, bool)
- func (t *NodeShiftTree[T]) Shape(v sitesmatrix.Vector) *NodeShiftTree[T]
- func (r *NodeShiftTree[T]) SiteVector() sitesmatrix.Vector
- func (t *NodeShiftTree[T]) String() string
- func (t *NodeShiftTree[T]) Unlock(writable bool)
- func (r *NodeShiftTree[T]) WalkPrefixRaw(prefix string, fn radix.WalkFn[T]) error
- type NodeShiftTreeWalker
- func (r *NodeShiftTreeWalker[T]) Extend() *NodeShiftTreeWalker[T]
- func (r *NodeShiftTreeWalker[T]) ShouldSkipKey(s string) bool
- func (r *NodeShiftTreeWalker[T]) ShouldSkipValue(s string, v T) bool
- func (r *NodeShiftTreeWalker[T]) SkipPrefix(prefix ...string)
- func (r *NodeShiftTreeWalker[T]) Walk(ctx context.Context) error
- func (r *NodeShiftTreeWalker[T]) WithPrefix(prefix string) *NodeShiftTreeWalker[T]
- type NodeTransformState
- type Shifter
- type SimpleThreadSafeTree
- func NewSimpleThreadSafeTree[T any]() *SimpleThreadSafeTree[T]
- func (tree *SimpleThreadSafeTree[T]) All(lockType LockType) iter.Seq2[string, T]
- func (tree *SimpleThreadSafeTree[T]) Get(s string) T
- func (tree *SimpleThreadSafeTree[T]) Insert(s string, v T) T
- func (tree *SimpleThreadSafeTree[T]) Lock(lockType LockType)
- func (tree *SimpleThreadSafeTree[T]) LongestPrefix(s string) (string, T)
- func (tree *SimpleThreadSafeTree[T]) Unlock(lockType LockType)
- func (tree *SimpleThreadSafeTree[T]) WalkPath(lockType LockType, s string, f func(s string, v T) (bool, error)) error
- func (tree *SimpleThreadSafeTree[T]) WalkPrefix(lockType LockType, s string, f func(s string, v T) (bool, error)) error
- type SimpleTree
- func NewSimpleTree[T any]() *SimpleTree[T]
- func (tree *SimpleTree[T]) All() iter.Seq2[string, T]
- func (tree *SimpleTree[T]) Get(s string) T
- func (tree *SimpleTree[T]) Insert(s string, v T) T
- func (tree *SimpleTree[T]) LongestPrefix(s string) (string, T)
- func (tree *SimpleTree[T]) Walk(f func(s string, v T) (bool, error)) error
- func (tree *SimpleTree[T]) WalkPath(s string, f func(s string, v T) (bool, error)) error
- func (tree *SimpleTree[T]) WalkPrefix(s string, f func(s string, v T) (bool, error)) error
- type Transformer
- type Tree
- type TreeCommon
- type TreeShiftTreeSlice
- func NewTreeShiftTree[T comparable](v sitesmatrix.Vector) *TreeShiftTreeSlice[T]
- func (t *TreeShiftTreeSlice[T]) All(lockType LockType) iter.Seq2[string, T]
- func (t *TreeShiftTreeSlice[T]) Delete(key string)
- func (t *TreeShiftTreeSlice[T]) DeleteAllFunc(s string, f func(s string, v T) bool)
- func (t *TreeShiftTreeSlice[T]) DeletePrefix(prefix string) int
- func (t *TreeShiftTreeSlice[T]) Get(s string) T
- func (t *TreeShiftTreeSlice[T]) Insert(s string, v T) T
- func (t *TreeShiftTreeSlice[T]) LenRaw() int
- func (t *TreeShiftTreeSlice[T]) Lock(lockType LockType)
- func (t *TreeShiftTreeSlice[T]) LongestPrefix(s string) (string, T)
- func (t TreeShiftTreeSlice[T]) Shape(v sitesmatrix.Vector) *TreeShiftTreeSlice[T]
- func (t *TreeShiftTreeSlice[T]) Trees() iter.Seq[*SimpleThreadSafeTree[T]]
- func (t *TreeShiftTreeSlice[T]) Unlock(lockType LockType)
- func (t *TreeShiftTreeSlice[T]) WalkPath(lockType LockType, s string, f func(s string, v T) (bool, error)) error
- func (t *TreeShiftTreeSlice[T]) WalkPrefix(lockType LockType, s string, f func(s string, v T) (bool, error)) error
- func (t *TreeShiftTreeSlice[T]) WalkPrefixRaw(lockType LockType, s string, f func(s string, v T) (bool, error)) error
- type TreeThreadSafe
- type WalkContext
- func (ctx *WalkContext[T]) AddEventListener(event, path string, handler func(*Event[T]))
- func (ctx *WalkContext[T]) Data() *SimpleThreadSafeTree[any]
- func (ctx *WalkContext[T]) DataRaw(vec sitesmatrix.Vector) *SimpleThreadSafeTree[any]
- func (ctx *WalkContext[T]) DataRawForEeach() iter.Seq2[sitesmatrix.Vector, *SimpleThreadSafeTree[any]]
- func (ctx *WalkContext[T]) HandleEvents() error
- func (ctx *WalkContext[T]) HandleEventsAndHooks() error
- func (ctx *WalkContext[T]) HooksPost() *collections.Stack[func() error]
- func (ctx *WalkContext[T]) SendEvent(event *Event[T])
- type WalkFunc
- type WalkableTree
- type WalkableTrees
Functions ¶
func ValidateKey ¶
ValidateKey returns an error if the key is not valid.
Types ¶
type Config ¶
type Config[T any] struct { // Shifter handles tree transformations. Shifter Shifter[T] TransformerRaw Transformer[T] }
type Event ¶
type Event[T any] struct { Name string Path string Source T // contains filtered or unexported fields }
Event is used to communicate events in the tree.
func (*Event[T]) StopPropagation ¶
func (e *Event[T]) StopPropagation()
StopPropagation stops the propagation of the event.
type LockType ¶
type LockType int
type MutableTree ¶
type MutableTree interface {
DeleteRaw(key string)
DeletePrefix(prefix string) int
DeletePrefixRaw(prefix string) int
Lock(writable bool)
Unlock(writable bool)
CanLock() bool // Used for troubleshooting only.
}
MutableTree is a tree that can be modified.
type MutableTrees ¶
type MutableTrees []MutableTree
func (MutableTrees) CanLock ¶
func (t MutableTrees) CanLock() bool
func (MutableTrees) DeletePrefix ¶
func (t MutableTrees) DeletePrefix(prefix string) int
func (MutableTrees) DeletePrefixRaw ¶
func (t MutableTrees) DeletePrefixRaw(prefix string) int
func (MutableTrees) DeleteRaw ¶
func (t MutableTrees) DeleteRaw(key string)
func (MutableTrees) Lock ¶
func (t MutableTrees) Lock(writable bool)
func (MutableTrees) Unlock ¶
func (t MutableTrees) Unlock(writable bool)
type NodeShiftTree ¶
type NodeShiftTree[T any] struct { // contains filtered or unexported fields }
NodeShiftTree is the root of a tree that can be shaped using the Shape method. Note that multiplied shapes of the same tree is meant to be used concurrently, so use the applicable locking when needed.
func New ¶
func New[T any](cfg Config[T]) *NodeShiftTree[T]
func (*NodeShiftTree[T]) AppendRaw ¶
func (r *NodeShiftTree[T]) AppendRaw(s string, ts ...T) (T, bool)
AppendRaw appends ts to the node at the given key without any shifting or transformation.
func (*NodeShiftTree[T]) CanLock ¶
func (t *NodeShiftTree[T]) CanLock() bool
func (*NodeShiftTree[T]) Delete ¶
func (r *NodeShiftTree[T]) Delete(key string) (T, bool)
Delete deletes the node at the given key in the current dimension.
func (*NodeShiftTree[T]) DeleteFuncRaw ¶
func (r *NodeShiftTree[T]) DeleteFuncRaw(key string, f func(T) bool) (T, int)
DeleteFuncRaw deletes nodes in the tree at the given key where the given function returns true. It will delete nodes in all dimensions.
func (*NodeShiftTree[T]) DeletePrefix ¶
func (r *NodeShiftTree[T]) DeletePrefix(prefix string) int
DeletePrefix deletes all nodes with the given prefix in the current dimension.
func (*NodeShiftTree[T]) DeletePrefixRaw ¶
func (t *NodeShiftTree[T]) DeletePrefixRaw(prefix string) int
func (*NodeShiftTree[T]) DeleteRaw ¶
func (r *NodeShiftTree[T]) DeleteRaw(key string)
DeleteRaw deletes the node at the given key without any shifting or transformation.
func (*NodeShiftTree[T]) ForEeachInAllDimensions ¶
func (r *NodeShiftTree[T]) ForEeachInAllDimensions(s string, f func(T) bool)
func (*NodeShiftTree[T]) ForEeachInDimension ¶
func (r *NodeShiftTree[T]) ForEeachInDimension(s string, dims sitesmatrix.Vector, d int, f func(T) bool)
func (*NodeShiftTree[T]) Get ¶
func (r *NodeShiftTree[T]) Get(s string) T
func (*NodeShiftTree[T]) GetRaw ¶
func (r *NodeShiftTree[T]) GetRaw(s string) (T, bool)
GetRaw returns the raw value at the given key without any shifting or transformation.
func (*NodeShiftTree[T]) Has ¶
func (r *NodeShiftTree[T]) Has(s string) bool
func (*NodeShiftTree[T]) Insert ¶
func (r *NodeShiftTree[T]) Insert(s string, v T) (T, T, bool)
Insert inserts v into the tree at the given key and the dimension defined by the value. It returns the updated and existing T and a bool indicating if an existing record is updated.
func (*NodeShiftTree[T]) InsertRaw ¶
func (r *NodeShiftTree[T]) InsertRaw(s string, v T) (T, bool)
InsertRaw inserts v into the tree at the given key without any shifting or transformation.
func (*NodeShiftTree[T]) InsertRawWithLock ¶
func (r *NodeShiftTree[T]) InsertRawWithLock(s string, v T) (T, bool)
func (*NodeShiftTree[T]) InsertWithLock ¶
func (r *NodeShiftTree[T]) InsertWithLock(s string, v T) (T, T, bool)
It returns the updated and existing T and a bool indicating if an existing record is updated.
func (*NodeShiftTree[T]) Len ¶
func (t *NodeShiftTree[T]) Len() int
func (*NodeShiftTree[T]) Lock ¶
func (t *NodeShiftTree[T]) Lock(writable bool)
Lock locks the data store for read or read/write access. Note that NodeShiftTree is not thread-safe outside of this transaction construct.
func (*NodeShiftTree[T]) LongestPrefiValueRaw ¶
func (r *NodeShiftTree[T]) LongestPrefiValueRaw(s string) (string, T)
LongestPrefiValueRaw returns the longest prefix and value considering all dimensions
func (*NodeShiftTree[T]) LongestPrefix ¶
func (r *NodeShiftTree[T]) LongestPrefix(s string, fallback bool, predicate func(v T) bool) (string, T)
LongestPrefix finds the longest prefix of s that exists in the tree that also matches the predicate (if set). Set exact to true to only match exact in the current dimension (e.g. language).
func (*NodeShiftTree[T]) LongestPrefixRaw ¶
func (r *NodeShiftTree[T]) LongestPrefixRaw(s string) (string, bool)
LongestPrefixRaw returns the longest prefix considering all dimensions.
func (*NodeShiftTree[T]) Shape ¶
func (t *NodeShiftTree[T]) Shape(v sitesmatrix.Vector) *NodeShiftTree[T]
Shape returns a new NodeShiftTree shaped to the given dimension.
func (*NodeShiftTree[T]) SiteVector ¶
func (r *NodeShiftTree[T]) SiteVector() sitesmatrix.Vector
SiteVector returns the site vector of the current dimension.
func (*NodeShiftTree[T]) String ¶
func (t *NodeShiftTree[T]) String() string
func (*NodeShiftTree[T]) Unlock ¶
func (t *NodeShiftTree[T]) Unlock(writable bool)
Unlock unlocks the data store.
func (*NodeShiftTree[T]) WalkPrefixRaw ¶
func (r *NodeShiftTree[T]) WalkPrefixRaw(prefix string, fn radix.WalkFn[T]) error
WalkPrefixRaw walks all nodes with the given prefix in the tree without any shifting or transformation.
type NodeShiftTreeWalker ¶
type NodeShiftTreeWalker[T any] struct { // The tree to walk. Tree *NodeShiftTree[T] // Transform will be called for each node in the main tree. // v2 will replace v1 in the tree if state returned is NodeTransformStateReplaced. Transform func(s string, v1 T) (v2 T, state NodeTransformState, err error) // Handle will be called for each node in the main tree. Handle func(s string, v T) (f radix.WalkFlag, err error) // Optional prefix filter. Prefix string // IncludeFilter is an optional filter that can be used to filter nodes. // If it returns false, the node will be skipped. // Note that v is the shifted value from the tree. IncludeFilter func(s string, v T) bool // IncludeRawFilter is an optional filter that can be used to filter nodes. // If it returns false, the node will be skipped. // Note that v is the raw value from the tree. IncludeRawFilter func(s string, v T) bool // Enable read or write locking if needed. LockType LockType // When set, no dimension shifting will be performed. NoShift bool // When set, will try to fall back to alternative match, // typically a shared resource common for all languages. Fallback bool // Used in development only. Debug bool // Optional context. // Note that this is copied to the nested walkers using Extend. // This means that walkers can pass data (down) and events (up) to // the related walkers. WalkContext *WalkContext[T] // contains filtered or unexported fields }
func (*NodeShiftTreeWalker[T]) Extend ¶
func (r *NodeShiftTreeWalker[T]) Extend() *NodeShiftTreeWalker[T]
Extend returns a new NodeShiftTreeWalker with the same configuration and the same WalkContext as the original. Any local state is reset.
func (*NodeShiftTreeWalker[T]) ShouldSkipKey ¶
func (r *NodeShiftTreeWalker[T]) ShouldSkipKey(s string) bool
func (*NodeShiftTreeWalker[T]) ShouldSkipValue ¶
func (r *NodeShiftTreeWalker[T]) ShouldSkipValue(s string, v T) bool
ShouldSkip returns whether the given value should be skipped in the walk.
func (*NodeShiftTreeWalker[T]) SkipPrefix ¶
func (r *NodeShiftTreeWalker[T]) SkipPrefix(prefix ...string)
SkipPrefix adds a prefix to be skipped in the walk.
func (*NodeShiftTreeWalker[T]) Walk ¶
func (r *NodeShiftTreeWalker[T]) Walk(ctx context.Context) error
func (*NodeShiftTreeWalker[T]) WithPrefix ¶
func (r *NodeShiftTreeWalker[T]) WithPrefix(prefix string) *NodeShiftTreeWalker[T]
WithPrefix returns a new NodeShiftTreeWalker with the given prefix.
type NodeTransformState ¶
type NodeTransformState int
const ( NodeTransformStateNone NodeTransformState = iota NodeTransformStateUpdated // Node is updated in place. NodeTransformStateReplaced // Node is replaced and needs to be re-inserted into the tree. NodeTransformStateDeleted // Node is deleted and should be removed from the tree. NodeTransformStateSkip // Skip this node, but continue the walk. NodeTransformStateTerminate // Terminate the walk. )
func (NodeTransformState) String ¶
func (i NodeTransformState) String() string
type Shifter ¶
type Shifter[T any] interface { // ForEeachInDimension will call the given function for each value in the given dimension d. // This is typicall used to e.g. walk all language translations of a given node. // If the function returns false, the walk will stop. ForEeachInDimension(n T, vec sitesmatrix.Vector, d int, f func(T) bool) // ForEeachInAllDimensions will call the given function for each value in all dimensions. // If the function returns false, the walk will stop. ForEeachInAllDimensions(n T, f func(T) bool) // Insert inserts new into the tree into the dimension it provides. // It may replace old. // It returns the updated and existing T // and a bool indicating if an existing record is updated. Insert(old, new T) (T, T, bool) // Delete deletes T from the given dimension and returns the deleted T and whether the dimension was deleted and if it's empty after the delete. Delete(v T, dimension sitesmatrix.Vector) (T, bool, bool) // DeleteFunc deletes nodes in v from the tree where the given function returns true. // It returns true if it's empty after the delete. DeleteFunc(v T, f func(n T) bool) bool // Shift shifts v into the given dimension, // if fallback is true, it will fall back a fallback match if found. // It returns the shifted T and a bool indicating if the shift was successful. Shift(v T, dimension sitesmatrix.Vector, fallback bool) (T, bool) }
Shifter handles tree transformations.
type SimpleThreadSafeTree ¶
type SimpleThreadSafeTree[T any] struct { // contains filtered or unexported fields }
SimpleThreadSafeTree is a thread safe radix tree that holds T.
func NewSimpleThreadSafeTree ¶
func NewSimpleThreadSafeTree[T any]() *SimpleThreadSafeTree[T]
NewSimpleThreadSafeTree creates a new SimpleTree.
func (*SimpleThreadSafeTree[T]) All ¶
func (tree *SimpleThreadSafeTree[T]) All(lockType LockType) iter.Seq2[string, T]
func (*SimpleThreadSafeTree[T]) Get ¶
func (tree *SimpleThreadSafeTree[T]) Get(s string) T
func (*SimpleThreadSafeTree[T]) Insert ¶
func (tree *SimpleThreadSafeTree[T]) Insert(s string, v T) T
func (*SimpleThreadSafeTree[T]) Lock ¶
func (tree *SimpleThreadSafeTree[T]) Lock(lockType LockType)
func (*SimpleThreadSafeTree[T]) LongestPrefix ¶
func (tree *SimpleThreadSafeTree[T]) LongestPrefix(s string) (string, T)
func (*SimpleThreadSafeTree[T]) Unlock ¶
func (tree *SimpleThreadSafeTree[T]) Unlock(lockType LockType)
func (*SimpleThreadSafeTree[T]) WalkPath ¶
func (tree *SimpleThreadSafeTree[T]) WalkPath(lockType LockType, s string, f func(s string, v T) (bool, error)) error
func (*SimpleThreadSafeTree[T]) WalkPrefix ¶
func (tree *SimpleThreadSafeTree[T]) WalkPrefix(lockType LockType, s string, f func(s string, v T) (bool, error)) error
type SimpleTree ¶
type SimpleTree[T any] struct { // contains filtered or unexported fields }
SimpleTree is a radix tree that holds T. This tree is not thread safe.
func NewSimpleTree ¶
func NewSimpleTree[T any]() *SimpleTree[T]
func (*SimpleTree[T]) All ¶
func (tree *SimpleTree[T]) All() iter.Seq2[string, T]
func (*SimpleTree[T]) Get ¶
func (tree *SimpleTree[T]) Get(s string) T
func (*SimpleTree[T]) Insert ¶
func (tree *SimpleTree[T]) Insert(s string, v T) T
func (*SimpleTree[T]) LongestPrefix ¶
func (tree *SimpleTree[T]) LongestPrefix(s string) (string, T)
func (*SimpleTree[T]) Walk ¶
func (tree *SimpleTree[T]) Walk(f func(s string, v T) (bool, error)) error
func (*SimpleTree[T]) WalkPath ¶
func (*SimpleTree[T]) WalkPrefix ¶
type Transformer ¶
type Transformer[T any] interface { // Append appends vs to t and returns the updated or replaced T and a bool indicating if T was replaced. // Note that t may be the zero value and should be ignored. Append(t T, ts ...T) (T, bool) }
type Tree ¶
type Tree[T any] interface { TreeCommon[T] WalkPrefix(s string, f func(s string, v T) (bool, error)) error WalkPath(s string, f func(s string, v T) (bool, error)) error All() iter.Seq2[string, T] }
Tree is a non thread safe radix tree that holds T.
type TreeCommon ¶
type TreeCommon[T any] interface { Get(s string) T LongestPrefix(s string) (string, T) Insert(s string, v T) T }
type TreeShiftTreeSlice ¶
type TreeShiftTreeSlice[T comparable] struct { // contains filtered or unexported fields }
func NewTreeShiftTree ¶
func NewTreeShiftTree[T comparable](v sitesmatrix.Vector) *TreeShiftTreeSlice[T]
func (*TreeShiftTreeSlice[T]) All ¶
func (t *TreeShiftTreeSlice[T]) All(lockType LockType) iter.Seq2[string, T]
func (*TreeShiftTreeSlice[T]) Delete ¶
func (t *TreeShiftTreeSlice[T]) Delete(key string)
func (*TreeShiftTreeSlice[T]) DeleteAllFunc ¶
func (t *TreeShiftTreeSlice[T]) DeleteAllFunc(s string, f func(s string, v T) bool)
func (*TreeShiftTreeSlice[T]) DeletePrefix ¶
func (t *TreeShiftTreeSlice[T]) DeletePrefix(prefix string) int
func (*TreeShiftTreeSlice[T]) Get ¶
func (t *TreeShiftTreeSlice[T]) Get(s string) T
func (*TreeShiftTreeSlice[T]) Insert ¶
func (t *TreeShiftTreeSlice[T]) Insert(s string, v T) T
func (*TreeShiftTreeSlice[T]) LenRaw ¶
func (t *TreeShiftTreeSlice[T]) LenRaw() int
func (*TreeShiftTreeSlice[T]) Lock ¶
func (t *TreeShiftTreeSlice[T]) Lock(lockType LockType)
func (*TreeShiftTreeSlice[T]) LongestPrefix ¶
func (t *TreeShiftTreeSlice[T]) LongestPrefix(s string) (string, T)
func (TreeShiftTreeSlice[T]) Shape ¶
func (t TreeShiftTreeSlice[T]) Shape(v sitesmatrix.Vector) *TreeShiftTreeSlice[T]
func (*TreeShiftTreeSlice[T]) Trees ¶
func (t *TreeShiftTreeSlice[T]) Trees() iter.Seq[*SimpleThreadSafeTree[T]]
func (*TreeShiftTreeSlice[T]) Unlock ¶
func (t *TreeShiftTreeSlice[T]) Unlock(lockType LockType)
func (*TreeShiftTreeSlice[T]) WalkPath ¶
func (t *TreeShiftTreeSlice[T]) WalkPath(lockType LockType, s string, f func(s string, v T) (bool, error)) error
func (*TreeShiftTreeSlice[T]) WalkPrefix ¶
func (t *TreeShiftTreeSlice[T]) WalkPrefix(lockType LockType, s string, f func(s string, v T) (bool, error)) error
func (*TreeShiftTreeSlice[T]) WalkPrefixRaw ¶
func (t *TreeShiftTreeSlice[T]) WalkPrefixRaw(lockType LockType, s string, f func(s string, v T) (bool, error)) error
type TreeThreadSafe ¶
type TreeThreadSafe[T any] interface { TreeCommon[T] WalkPrefix(lockType LockType, s string, f func(s string, v T) (bool, error)) error WalkPath(lockType LockType, s string, f func(s string, v T) (bool, error)) error All(lockType LockType) iter.Seq2[string, T] }
TreeThreadSafe is a thread safe radix tree that holds T.
type WalkContext ¶
type WalkContext[T any] struct { // contains filtered or unexported fields }
WalkContext is passed to the Walk callback.
func (*WalkContext[T]) AddEventListener ¶
func (ctx *WalkContext[T]) AddEventListener(event, path string, handler func(*Event[T]))
AddEventListener adds an event listener to the tree. Note that the handler func may not add listeners.
func (*WalkContext[T]) Data ¶
func (ctx *WalkContext[T]) Data() *SimpleThreadSafeTree[any]
func (*WalkContext[T]) DataRaw ¶
func (ctx *WalkContext[T]) DataRaw(vec sitesmatrix.Vector) *SimpleThreadSafeTree[any]
func (*WalkContext[T]) DataRawForEeach ¶
func (ctx *WalkContext[T]) DataRawForEeach() iter.Seq2[sitesmatrix.Vector, *SimpleThreadSafeTree[any]]
func (*WalkContext[T]) HandleEvents ¶
func (ctx *WalkContext[T]) HandleEvents() error
func (*WalkContext[T]) HandleEventsAndHooks ¶
func (ctx *WalkContext[T]) HandleEventsAndHooks() error
func (*WalkContext[T]) HooksPost ¶
func (ctx *WalkContext[T]) HooksPost() *collections.Stack[func() error]
func (*WalkContext[T]) SendEvent ¶
func (ctx *WalkContext[T]) SendEvent(event *Event[T])
SendEvent sends an event up the tree.
type WalkFunc ¶
type WalkableTree ¶
WalkableTree is a tree that can be walked.
type WalkableTrees ¶
type WalkableTrees[T any] []WalkableTree[T]
func (WalkableTrees[T]) WalkPrefixRaw ¶
func (t WalkableTrees[T]) WalkPrefixRaw(prefix string, walker radix.WalkFn[T]) error
Source Files ¶
nodeshifttree.go nodetransformstate_string.go simpletree.go support.go treeshifttree.go
- Version
- v0.153.4 (latest)
- Published
- Dec 28, 2025
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 4 months ago –
Tools for package owners.