/// <summary> /// Adds a series of transitions labeled with the elements of a given sequence to the current state, /// as well as the intermediate states. All the added transitions have unit weight. /// </summary> /// <param name="sequence">The sequence.</param> /// <param name="destinationState"> /// The last state in the transition series. /// If the value of this parameter is <see langword="null"/>, a new state will be created. /// </param> /// <param name="group">The group of the added transitions.</param> /// <returns>The last state in the added transition series.</returns> public State AddTransitionsForSequence(TSequence sequence, State destinationState = null, byte group = 0) { State currentState = this; IEnumerator <TElement> enumerator = sequence.GetEnumerator(); bool moveNext = enumerator.MoveNext(); while (moveNext) { TElement element = enumerator.Current; moveNext = enumerator.MoveNext(); currentState = currentState.AddTransition(element, Weight.One, moveNext ? null : destinationState, group); } return(currentState); }
/// <summary> /// Adds a series of transitions labeled with the elements of a given sequence to the current state, /// as well as the intermediate states. All the added transitions have unit weight. /// </summary> /// <param name="sequence">The sequence.</param> /// <param name="destinationState"> /// The last state in the transition series. /// If the value of this parameter is <see langword="null"/>, a new state will be created. /// </param> /// <param name="group">The group of the added transitions.</param> /// <returns>The last state in the added transition series.</returns> public State AddTransitionsForSequence(TSequence sequence, State destinationState = default(State), int group = 0) { var currentState = this; using (var enumerator = sequence.GetEnumerator()) { var moveNext = enumerator.MoveNext(); while (moveNext) { var element = enumerator.Current; moveNext = enumerator.MoveNext(); currentState = currentState.AddTransition( element, Weight.One, moveNext ? default(State) : destinationState, group); } } return(currentState); }
/// <summary> /// Adds a series of transitions labeled with the elements of a given sequence to the current state, /// as well as the intermediate states. All the added transitions have unit weight. /// </summary> /// <param name="sequence">The sequence.</param> /// <param name="destinationStateIndex"> /// The last state in the transition series. /// If the value of this parameter is <see langword="null"/>, a new state will be created. /// </param> /// <param name="group">The group of the added transitions.</param> /// <returns>The last state in the added transition series.</returns> public StateBuilder AddTransitionsForSequence( TSequence sequence, int?destinationStateIndex = null, int group = 0) { var currentState = this; using (var enumerator = sequence.GetEnumerator()) { var moveNext = enumerator.MoveNext(); while (moveNext) { var element = enumerator.Current; moveNext = enumerator.MoveNext(); currentState = currentState.AddTransition( element, Weight.One, moveNext ? null : destinationStateIndex, group); } } return(currentState); }