Esempio n. 1
0
File: FTree.cs Progetto: Luxg520/L01
    public void InsertWord(string word)
    {
        if (string.IsNullOrEmpty(word))
        {
            return;
        }

        char[] chs = word.ToCharArray();

        int   index    = 0;
        FNode nextNode = null;

        while (index < chs.Length)
        {
            ushort key = (ushort)chs[index++];

            if (nextNode == null)
            {
                nextNode = FTreeHelper.BinaryInsert(key, childs);
            }
            else
            {
                nextNode = nextNode.InsertChild(key);
            }
        }

        nextNode.terminated = true;
    }