public override void EnumerateTransitions(DfaTransitionConsumer <int> consumer) { for (var i = 0; i < transitions.Count; ++i) { consumer((char)i, (char)i, transitions[i]); } }
public override void EnumerateTransitions(DfaTransitionConsumer <TResult> consumer) { if (internalNodes.Length < 1) { if (targetStates[0] != null) { consumer('\0', Char.MaxValue, targetStates[0]); } return; } var lastInternal = EnumInternal(consumer, 0, -1); var lastC = internalNodes[lastInternal]; if (lastC >= char.MaxValue) { return; } DfaState <TResult> state = targetStates[lastInternal * 2 + 2 - internalNodes.Length]; if (state != null) { consumer(lastC, char.MaxValue, state); } }
private int EnumInternal(DfaTransitionConsumer <TResult> consumer, int target, int prevInternal) { var child = target * 2 + 1; //left child of target if (child < internalNodes.Length) { prevInternal = EnumInternal(consumer, child, prevInternal); } DfaState <TResult> state; var cFrom = (prevInternal < 0 ? 0 : internalNodes[prevInternal]); var cTo = internalNodes[target] - 1; //between adjacent internal nodes is a leaf if (prevInternal > target) { state = targetStates[prevInternal * 2 + 2 - internalNodes.Length]; } else { state = targetStates[target * 2 + 1 - internalNodes.Length]; } if (state != null && cFrom <= cTo) { consumer((char)cFrom, (char)cTo, state); } prevInternal = target; ++child; // right child of target if (child < internalNodes.Length) { prevInternal = EnumInternal(consumer, child, prevInternal); } return(prevInternal); }
public sealed override void EnumerateTransitions(DfaTransitionConsumer <TResult> consumer) { Delegate.EnumerateTransitions(consumer); }
/// <summary> /// Enumerate all the transitions out of this state /// </summary> /// <param name="consumer">each DFA transition will be sent here</param> public abstract void EnumerateTransitions(DfaTransitionConsumer <TResult> consumer);