Exemple #1
0
        private bool AddNextSuffix()
        {
            var suffix = string.Concat(Word.Substring(CurrentSuffixStartIndex, CurrentSuffixEndIndex - CurrentSuffixStartIndex), "{", Word[CurrentSuffixEndIndex], "}");

            SendMessage("The next suffix of '{0}' to add is '{1}' at indices {2},{3}", Word, suffix, CurrentSuffixStartIndex, CurrentSuffixEndIndex);
            SendMessage(" => ActiveNode:             {0}", ActiveNode);
            SendMessage(" => ActiveEdge:             {0}", ActiveEdge == null ? "none" : ActiveEdge.ToString());
            SendMessage(" => DistanceIntoActiveEdge: {0}", DistanceIntoActiveEdge);
            SendMessage(" => UnresolvedSuffixes:     {0}", UnresolvedSuffixes);
            if (ActiveEdge != null && DistanceIntoActiveEdge >= ActiveEdge.Length)
            {
                throw new Exception("BOUNDARY EXCEEDED");
            }

            if (ActiveEdge != null)
            {
                return(AddCurrentSuffixToActiveEdge());
            }

            if (GetExistingEdgeAndSetAsActive())
            {
                return(false);
            }

            ActiveNode.AddNewEdge();
            TriggerChanged();

            UpdateActivePointAfterAddingNewEdge();
            return(true);
        }