Documentation ¶
Overview ¶
Inspired by https://github.com/akitasoftware/akita-libs/blob/main/path_trie/path_trie.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PathToTrieNode ¶
type PathTrie ¶
type PathTrie struct { Trie PathToTrieNode PathSeparator string }
func NewWithPathSeparator ¶
Create a PathTrie with a user-supplied path separator.
func (*PathTrie) GetPathAndValue ¶
GetPathAndValue returns the given node full path and value, nil if node is not found.
func (*PathTrie) Insert ¶
Insert val at path, with path segments separated by PathSeparator. Returns true if a new path was created, false if an existing path was overwritten.
func (*PathTrie) InsertMerge ¶
func (pt *PathTrie) InsertMerge(path string, val interface{}, merge ValueMergeFunc) (isNewPath bool)
Insert val at path, with path segments separated by PathSeparator. Returns true if a new path was created, false if an existing path was overwritten.
The merge function is responsible for updating the existing value with the new value.
type TrieNode ¶
type TrieNode struct { Children PathToTrieNode // Name of the path segment corresponding to this node. // E.g. if this node represents /v1/foo/bar, // the Name would be "bar" and the FullPath would be "/v1/foo/bar". Name string // FullPath includes the node's name and uniquely identifies the node in the tree. FullPath string // PathParamCounter counts the amount of path params in the FullPath PathParamCounter int // Value of the full path Value interface{} }
type ValueMergeFunc ¶
type ValueMergeFunc func(existing, newV *interface{})
Click to show internal directories.
Click to hide internal directories.