Exemplo n.º 1
0
 private Boolean TryRelateWithExistPathToEnd(RelatedNode currentNode, String word)
 {
     foreach (var startNode in GetStartNodesArriveToEnd(word.Length))
     {
         if (startNode.ExistPathToEnd(word))
         {
             currentNode.RelateWithNext(startNode, word.First());
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
    public void AddBranch(String word)
    {
        RelatedNode currentNode = startNode;

        foreach (var symbol in word)
        {
            var nextNode = currentNode.GetRelatedNodeByOutput(symbol);
            if (nextNode == null)
            {
                nextNode = CreateNode();
                currentNode.RelateWithNext(nextNode, symbol);
            }
            currentNode = nextNode;
        }
    }