Exemplo n.º 1
0
        public SearchNode Find(string search, int pos = 0)
        {
            TraversalOption nextStep = new TraversalOption(Label, search, pos);

            switch (nextStep.option)
            {
            case TraversalOptions.Split:
                return((nextStep.commonPrefixLength + pos == search.Length) ? this : null);

            case TraversalOptions.Found:
                return(this);

            case TraversalOptions.MoveNext:
                return(NextNode?.Find(search, pos));

            case TraversalOptions.MoveDown:
                return(ChildNode?.Find(search, pos + nextStep.commonPrefixLength));

            default:
                return(null);
            }
        }