Trie
Package trie implements a in-memory trie tree.
https://pkg.go.dev/github.com/hit9/trie
Example
package main
import (
"fmt"
"github.com/hit9/trie"
)
func main() {
tr := trie.New(".")
tr.Put("a.b.c", "data1")
tr.Put("a.b.c.d", "data2")
tr.Put("a.b.c.d.e", "data3")
tr.Put("a.b.m.n.p", "data4")
tr.Put("a.b.m.s.t", "data5")
fmt.Println(tr.Get("a.b.c"))
m := tr.Match("a.*.m.*.*")
fmt.Println(m)
tr1 := trie.New(".")
tr1.Put("a.*.c.*", "data1")
tr1.Put("a.b.c.*", "data2")
m = tr1.Matched("a.b.c.d")
fmt.Println(m)
}
License
BSD.