Questions tagged «finite-automata»

19
有没有典型的状态机实施模式?
我们需要在C中实现一个简单的状态机。 标准的switch语句是最好的方法吗? 我们有一个当前状态(状态)和一个转换触发器。 switch(state) { case STATE_1: state = DoState1(transition); break; case STATE_2: state = DoState2(transition); break; } ... DoState2(int transition) { // Do State Work ... if(transition == FROM_STATE_2) { // New state when doing STATE 2 -> STATE 2 } if(transition == FROM_STATE_1) { // New State when …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.