/// <summary> /// Constructor /// This is the only constructor in the API. /// </summary> public StateMachineFactory(STATE defaultInitialState) { this.transitionsListNode = null; this.defaultInitialState = defaultInitialState; this.optimized = false; this.stateMachineTable = null; }
internal TransitionsListNode(StateMachineFactory <Operand, State, Eventtype, Event > _enclosing, StateMachineFactory.ApplicableTransition <OPERAND, STATE, EVENTTYPE , EVENT> transition, StateMachineFactory.TransitionsListNode next) { this._enclosing = _enclosing; this.transition = transition; this.next = next; }
private StateMachineFactory(Org.Apache.Hadoop.Yarn.State.StateMachineFactory <OPERAND , STATE, EVENTTYPE, EVENT> that, StateMachineFactory.ApplicableTransition <OPERAND , STATE, EVENTTYPE, EVENT> t) { this.defaultInitialState = that.defaultInitialState; this.transitionsListNode = new StateMachineFactory.TransitionsListNode(this, t, that .transitionsListNode); this.optimized = false; this.stateMachineTable = null; }
private StateMachineFactory(Org.Apache.Hadoop.Yarn.State.StateMachineFactory <OPERAND , STATE, EVENTTYPE, EVENT> that, bool optimized) { this.defaultInitialState = that.defaultInitialState; this.transitionsListNode = that.transitionsListNode; this.optimized = optimized; if (optimized) { MakeStateMachineTable(); } else { stateMachineTable = null; } }
private void MakeStateMachineTable() { Stack <StateMachineFactory.ApplicableTransition <OPERAND, STATE, EVENTTYPE, EVENT> > stack = new Stack <StateMachineFactory.ApplicableTransition <OPERAND, STATE, EVENTTYPE , EVENT> >(); IDictionary <STATE, IDictionary <EVENTTYPE, StateMachineFactory.Transition <OPERAND, STATE, EVENTTYPE, EVENT> > > prototype = new Dictionary <STATE, IDictionary <EVENTTYPE , StateMachineFactory.Transition <OPERAND, STATE, EVENTTYPE, EVENT> > >(); prototype[defaultInitialState] = null; // I use EnumMap here because it'll be faster and denser. I would // expect most of the states to have at least one transition. stateMachineTable = new EnumMap <STATE, IDictionary <EVENTTYPE, StateMachineFactory.Transition <OPERAND, STATE, EVENTTYPE, EVENT> > >(prototype); for (StateMachineFactory.TransitionsListNode cursor = transitionsListNode; cursor != null; cursor = cursor.next) { stack.Push(cursor.transition); } while (!stack.IsEmpty()) { stack.Pop().Apply(this); } }