Example #1
0
        /// <summary>
        /// Keep comparing original text from position i
        /// with what is in the edge
        /// </summary>
        /// <param name="i">Index of comparison start in the original text</param>
        /// <param name="activeLength"></param>
        /// <param name="minDistance"></param>
        /// <param name="activeNode"></param>
        /// <returns>(edge, index) - the edje the character in it where the walk ended</returns>
        internal Tuple <Edge, int> WalkTheEdge(int i, ref int activeLength, ref int minDistance, ref Node activeNode)
        {
            var text           = SuffixTree.Text;
            var skipCharacters = minDistance;
            var index          = i + activeLength;

            // we know we do not need any comparisons on this edge
            if (skipCharacters >= Route.Length)
            {
                var edge = EndNode.FindEdgeByChar(i + Route.Length);
                activeLength += Route.Length;
                minDistance  -= Route.Length;

                activeNode = EndNode;
                return(edge.WalkTheEdge(i, ref activeLength, ref minDistance, ref activeNode));
            }

            var j = Walk(text, index, skipCharacters);

            return(new Tuple <Edge, int>(this, j));
        }