github.com/chwjbn/xclash@v0.2.0/component/trie/node.go (about) 1 package trie 2 3 // Node is the trie's node 4 type Node struct { 5 Data interface{} 6 children map[string]*Node 7 } 8 9 func (n *Node) getChild(s string) *Node { 10 return n.children[s] 11 } 12 13 func (n *Node) hasChild(s string) bool { 14 return n.getChild(s) != nil 15 } 16 17 func (n *Node) addChild(s string, child *Node) { 18 n.children[s] = child 19 } 20 21 func newNode(data interface{}) *Node { 22 return &Node{ 23 Data: data, 24 children: map[string]*Node{}, 25 } 26 }