public void MoveTo(CharacterLocation location)
		{
			CurrentNode = location.CurrentNode;
			Distance = location.Distance;
		}
Example #2
0
		/// <summary>
		/// Set the given location to the end location of the String[suffixOffset+1 .. suffixOffset+len] in the tree.
		/// (Move to-from units down, searching for nodes along the given substring)
		/// </summary>
		public void SetNextSuffixLocation(int from, int to, CharacterLocation location)
		{
			SuffixNode curNode = this;			// current Node
			var remaining = 0;
			for (var idx = from; idx < to; )
			{
				var c = Tree.String[idx];
				curNode = curNode.GetChild(c);
				var edgeLen = curNode.EdgeLength;
				remaining = to - idx;
				if (remaining > edgeLen)
				{
					// keep going down
					idx += edgeLen;
				}
				else if (remaining == edgeLen)
				{
					// move onto the node
					idx += edgeLen;
					location.MoveTo(curNode);
					return;
				}
				else
				{
					// done
					break;
				}
			}

			location.MoveTo(curNode, remaining);
		}