Ejemplo n.º 1
0
    public void Build(IReadOnlyList <string> tokens, int cur_index)
    {
        string next_token = tokens[cur_index];

        bool found = false;

        foreach (var next_node in next_nodes)
        {
            if (next_node.token == next_token)
            {
                if (cur_index < tokens.Count - 1)
                {
                    next_node.Build(tokens, cur_index + 1);
                }
                found = true;
            }
        }

        if (!found)
        {
            FootPrintTrieNode new_next_node = new FootPrintTrieNode(next_token);
            next_nodes.Add(new_next_node);
            if (cur_index < tokens.Count - 1)
            {
                new_next_node.Build(tokens, cur_index + 1);
            }
        }
    }
Ejemplo n.º 2
0
 public FootPrintTrie()
 {
     root = new FootPrintTrieNode(string.Empty);
 }