github.com/igoogolx/clash@v1.19.8/component/trie/node.go (about)

     1  package trie
     2  
     3  // Node is the trie's node
     4  type Node struct {
     5  	children map[string]*Node
     6  	Data     any
     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 any) *Node {
    22  	return &Node{
    23  		Data:     data,
    24  		children: map[string]*Node{},
    25  	}
    26  }