Exemplo n.º 1
0
Arquivo: FTree.cs Projeto: 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;
    }
Exemplo n.º 2
0
Arquivo: FTree.cs Projeto: Luxg520/L01
    public bool Process(char[] chs, int offset, ref int result)
    {
        FNode nextNode = null;

        result = -1;

        int index = offset;

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

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

            if (nextNode == null)
            {
                break;
            }

            if (nextNode.terminated)
            {
                result = index;
            }
        }

        return(result != -1);
    }
Exemplo n.º 3
0
Arquivo: FTree.cs Projeto: Luxg520/L01
    public FNode InsertChild(ushort key)
    {
        if (childs == null)
        {
            childs = new List <FNode>();
        }

        return(FTreeHelper.BinaryInsert(key, childs));
    }
Exemplo n.º 4
0
Arquivo: FTree.cs Projeto: Luxg520/L01
    public FNode BinarySearch(ushort key)
    {
        if (childs == null)
        {
            return(null);
        }

        return(FTreeHelper.BinarySearch(key, childs));
    }