Ejemplo n.º 1
0
        private bool TryFindDepthFirst(string path, int currentDepth, out LcrsNode node)
        {
            node = Step();

            if (node != LcrsNode.MinValue && node.Depth != currentDepth)
            {
                Skip(node.Weight - 1);
                node = Step();
            }

            if (node != LcrsNode.MinValue)
            {
                if (node.Value == path[currentDepth])
                {
                    if (currentDepth == path.Length - 1)
                    {
                        return(true);
                    }
                    // Go left (deep)
                    return(TryFindDepthFirst(path, currentDepth + 1, out node));
                }
                // Go right (wide)
                return(TryFindDepthFirst(path, currentDepth, out node));
            }

            return(false);
        }
Ejemplo n.º 2
0
        private bool TryFindDepthFirst(string path, out LcrsNode node)
        {
            var currentDepth = 0;

            node = Step();

            while (node != LcrsNode.MinValue)
            {
                if (node.Depth != currentDepth)
                {
                    Skip(node.Weight - 1);
                    node = Step();
                }

                if (node == LcrsNode.MinValue)
                {
                    return(false);
                }

                if (node.Value == path[currentDepth])
                {
                    if (currentDepth == path.Length - 1)
                    {
                        return(true);
                    }
                    // Go left (deep)
                    currentDepth++;
                }
                // Or go right (wide)

                node = Step();
            }
            return(false);
        }
Ejemplo n.º 3
0
 private void SkipToSibling(LcrsNode node)
 {
     while (true)
     {
         var test = Step();
         if (test.Depth <= node.Depth)
         {
             Rewind();
             break;
         }
     }
 }
Ejemplo n.º 4
0
        private bool TryFindDepthFirst(string path, out LcrsNode node, bool greaterThan = false)
        {
            var currentDepth = 0;

            node = Step();

            while (node != LcrsNode.MinValue)
            {
                if (node.Value == Serializer.SegmentDelimiter)
                {
                    break;
                }

                if (node.Depth != currentDepth)
                {
                    Skip(node.Weight - 1);
                    node = Step();
                }

                if (node == LcrsNode.MinValue)
                {
                    return(false);
                }
                else if (node.Value == Serializer.SegmentDelimiter)
                {
                    break;
                }

                if ((greaterThan && node.Value >= path[currentDepth]) ||
                    (node.Value == path[currentDepth]))
                {
                    if (currentDepth == path.Length - 1)
                    {
                        return(true);
                    }

                    // Go left (deep)
                    currentDepth++;
                }

                // Or go right (wide)
                node = Step();
            }
            return(false);
        }
Ejemplo n.º 5
0
 private void Rewind()
 {
     Replay = LastRead;
 }
Ejemplo n.º 6
0
 protected TrieReader()
 {
     LastRead = LcrsNode.MinValue;
     Replay   = LcrsNode.MinValue;
 }