mirror of
				https://github.com/xjasonlyu/tun2socks.git
				synced 2025-10-31 03:56:30 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			436 B
		
	
	
	
		
			Go
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			436 B
		
	
	
	
		
			Go
		
	
	
		
			Executable File
		
	
	
	
	
| package trie
 | |
| 
 | |
| // Node is the trie's node
 | |
| type Node struct {
 | |
| 	Data     interface{}
 | |
| 	children map[string]*Node
 | |
| }
 | |
| 
 | |
| 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{},
 | |
| 	}
 | |
| }
 | 
