package Trie;
import java.util.TreeMap;
public class Trie {
private class Node{
public boolean isWord; //记录该Node是不是一个字符串的结尾
public TreeMap<Character, Node> next; //该Node的下一个Node的Map
public Node(boolean isWord){
this.isWord = isWord;
this.next = new TreeMap<>();
}
public Node(){
this(false);
}
}
private Node root;
private int size;
public Trie(){
root = new Node();
this.size = 0;
}
//向Trie中添加字符串
public void add(String word){
Node cur = root;
for (int i=0; i<word.length(); i++){
char c = word.charA