mihomo/component/trie/node.go

27 lines
436 B
Go
Raw Normal View History

2019-07-14 19:29:58 +08:00
package trie
// Node is the trie's node
type Node struct {
children map[string]*Node
2022-01-26 22:28:13 +08:00
Data interface{}
2019-07-14 19:29:58 +08:00
}
func (n *Node) getChild(s string) *Node {
return n.children[s]
}
func (n *Node) hasChild(s string) bool {
return n.getChild(s) != nil
}
func (n *Node) addChild(s string, child *Node) {
n.children[s] = child
}
func newNode(data interface{}) *Node {
return &Node{
Data: data,
children: map[string]*Node{},
}
}