Exemple #1
0
        public unsafe int CommonPrefixSearch(byte *key, ResultPair *result, int resultLen, int len, int nodePos = 0)
        {
            int b   = this.array[nodePos].Base;
            int num = 0;
            int n;
            int p;

            for (int i = 0; i < len; i++)
            {
                p = b;
                n = this.array[p].Base;

                if (b == this.array[p].Check && n < 0)
                {
                    if (num < resultLen)
                    {
                        result[num] = new ResultPair()
                        {
                            Value = -n - 1, Length = i
                        }
                    }
                    ;
                    num++;
                }

                p = b + key[i] + 1;
                if (b == this.array[p].Check)
                {
                    b = this.array[p].Base;
                }
                else
                {
                    return(num);
                }
            }

            p = b;
            n = this.array[p].Base;

            if (b == this.array[p].Check && n < 0)
            {
                if (num < resultLen)
                {
                    result[num] = new ResultPair()
                    {
                        Value = -n - 1, Length = len
                    }
                }
                ;
                num++;
            }

            return(num);
        }

        #endregion
    }
}
Exemple #2
0
        public unsafe int CommonPrefixSearch(byte *key, ResultPair *result, int resultLen, int len, int nodePos = 0)
        {
            int  b   = this.ReadBase(nodePos);
            int  num = 0;
            int  n;
            Unit p;

            for (int i = 0; i < len; i++)
            {
                this.ReadUnit(b, out p);
                n = p.Base;

                if (b == p.Check && n < 0)
                {
                    if (num < resultLen)
                    {
                        result[num] = new ResultPair(-n - 1, i);
                    }
                    num++;
                }

                this.ReadUnit(b + key[i] + 1, out p);
                if (b == p.Check)
                {
                    b = p.Base;
                }
                else
                {
                    return(num);
                }
            }

            this.ReadUnit(b, out p);
            n = p.Base;

            if (b == p.Check && n < 0)
            {
                if (num < resultLen)
                {
                    result[num] = new ResultPair(-n - 1, len);
                }
                num++;
            }

            return(num);
        }
Exemple #3
0
        public unsafe int CommonPrefixSearch(byte *key, ResultPair *result, int resultLen, int len, int nodePos = 0)
        {
            int  num  = this.ReadBase(nodePos);
            int  num2 = 0;
            Unit unit = default(Unit);
            int  @base;

            for (int i = 0; i < len; i++)
            {
                this.ReadUnit(num, out unit);
                @base = unit.Base;
                if (num == unit.Check && @base < 0)
                {
                    if (num2 < resultLen)
                    {
                        result[num2] = new ResultPair(-@base - 1, i);
                    }
                    num2++;
                }
                this.ReadUnit(num + key[i] + 1, out unit);
                if (num != unit.Check)
                {
                    return(num2);
                }
                num = unit.Base;
            }
            this.ReadUnit(num, out unit);
            @base = unit.Base;
            if (num == unit.Check && @base < 0)
            {
                if (num2 < resultLen)
                {
                    result[num2] = new ResultPair(-@base - 1, len);
                }
                num2++;
            }
            return(num2);
        }
Exemple #4
0
 public unsafe void ExactMatchSearch(byte *key, ResultPair *result, int len, int nodePos)
 {
     *result = this.ExactMatchSearch(key, len, nodePos);
 }