Ejemplo n.º 1
0
Archivo: FTree.cs Proyecto: 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;
    }
Ejemplo n.º 2
0
Archivo: FTree.cs Proyecto: 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);
    }
Ejemplo n.º 3
0
Archivo: FTree.cs Proyecto: Luxg520/L01
    public FNode InsertChild(ushort key)
    {
        if (childs == null)
        {
            childs = new List <FNode>();
        }

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

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