Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const Separator = '/'
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PathTrie ¶
PathTrie 表示路径前缀树
func NewPathTrie ¶
NewPathTrie 创建新的 PathTrie
Example ¶
package main
import (
"fmt"
"github.com/omalloc/tavern/pkg/pathtrie"
)
func main() {
trie := pathtrie.NewPathTrie[string, int64]()
trie.Insert("/api/users", 0)
trie.Insert("http://sendya.me.gslb.com/host/path/", 1768480300)
value1, found1 := trie.Search("/api/users/123")
value7, found7 := trie.Search("http://sendya.me.gslb.com/host/path/to/1M")
fmt.Printf("value1: %d found: %t\n", value1, found1)
fmt.Printf("value7: %d found: %t\n", value7, found7)
}
Output: value1: 0 found: true value7: 1768480300 found: true
func (*PathTrie[K, T]) FindByPrefix ¶
FindByPrefix 通过前缀查找所有匹配的路径和值
Click to show internal directories.
Click to hide internal directories.