本文整理汇总了C#中State.AddTransitionTo方法的典型用法代码示例。如果您正苦于以下问题:C# State.AddTransitionTo方法的具体用法?C# State.AddTransitionTo怎么用?C# State.AddTransitionTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State.AddTransitionTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTrapState
private State AddTrapState(FiniteAutomata dfa)
{
var trapState = new State("trap") {Id = int.MaxValue};
for (int i = 0; i <= Byte.MaxValue; i++)
{
trapState.AddTransitionTo(trapState, InputChar.For((byte) i));
}
var states = dfa.GetStates();
foreach (var state in states)
{
bool[] usedTransitions = new bool[Byte.MaxValue + 1]; // All nulls
foreach (var transition in state.Transitions)
{
usedTransitions[transition.Key.Value] = true; // mark used symbol
}
for (int i = 0; i <= Byte.MaxValue; i++)
{
if (!usedTransitions[i])
{
state.AddTransitionTo(trapState, InputChar.For((byte)i));
}
}
}
return trapState;
}
示例2: ComplementTransitions
// Adds transitions for bytes for which no transition is set. The target state for
// newly created transitions is targetState
private static void ComplementTransitions(State state, State targetState)
{
for (int i = 0; i < Byte.MaxValue + 1; i++)
{
var inputChar = InputChar.For((byte) i);
List<State> statesList;
// If no transition on i at all
if (!state.Transitions.TryGetValue(inputChar, out statesList) || statesList.Count == 0)
{
state.AddTransitionTo(targetState, inputChar);
}
else if (statesList[0].IsAccepting) // If this transition is to the Terminator of ignorees tree
{
// Delete it
state.Transitions.Remove(inputChar);
}
}
}