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); }
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); }
private void SkipToSibling(LcrsNode node) { while (true) { var test = Step(); if (test.Depth <= node.Depth) { Rewind(); break; } } }
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); }
private void Rewind() { Replay = LastRead; }
protected TrieReader() { LastRead = LcrsNode.MinValue; Replay = LcrsNode.MinValue; }