示例#1
0
 public void insert(string num)
 {
     TrieNode here = root;
     foreach (char c in num){
         if (here.getChild((int)c) == null){
             TrieNode newChild = new TrieNode(c);
             here.setChild((int)c, c);
         }
         here = here.getChild((int)c);
     }
     here.getChild((int)num[num.Length-1]).setEnd(true);//set isWordEnd = true
 }
 public void setChild(int i, char l)
 {
     theChildren[i] = new TrieNode(l);
 }
示例#3
0
 public Trie()
 {
     root = new TrieNode(' ');
 }