本文整理汇总了C++中Automaton::IsStateFinal方法的典型用法代码示例。如果您正苦于以下问题:C++ Automaton::IsStateFinal方法的具体用法?C++ Automaton::IsStateFinal怎么用?C++ Automaton::IsStateFinal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Automaton
的用法示例。
在下文中一共展示了Automaton::IsStateFinal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StateIsFinal
/**
* Implementation of workset-based algorithm for deciding whether the given
* macro-state is final or not. Macro-state is final if all its substates are
* non-final
*
* @param aut: automaton // FOR NOW! may be replaced by cache
* @param state: macro state we are checking
* @param level: level of projection
* @return True if the macro-state is final
*/
bool StateIsFinal(Automaton & aut, TStateSet* state, unsigned level, PrefixListType & prefix) {
// return whether the state is final in automaton
if (level == 0) {
LeafStateSet* leaf = reinterpret_cast<LeafStateSet*>(state);
StateType q = leaf->state;
return aut.IsStateFinal(q);
// level > 0
} else {
StateSetList worklist;
StateSetList processed;
MacroStateSet* macroState = reinterpret_cast<MacroStateSet*>(state);
// Look into Cache
bool isFinal;
#ifdef USE_STATECACHE
if(StateCache.retrieveFromCache(macroState, isFinal, level)) {
return isFinal;
}
#endif
// enqueue initial states
StateSetList states = macroState->getMacroStates();
for (auto state : states) {
worklist.push_back(state);
}
while (worklist.size() != 0) {
TStateSet* q = worklist.back();
worklist.pop_back();
processed.push_back(q);
if (StateIsFinal(aut, q, level - 1, prefix)) {
#ifdef USE_STATECACHE
StateCache.storeIn(macroState, false, level);
#endif
return false;
} else {
// Enqueue all its successors
MacroStateSet* zeroSuccessor = GetZeroPost(aut, q, level-1, prefix);
if ((level - 1) == 0) {
StateSetList s = zeroSuccessor->getMacroStates();
for(auto it = s.begin(); it != s.end(); ++it) {
if(isNotEnqueued(processed, *it, level-1)) {
StateType leafState = reinterpret_cast<LeafStateSet*>(*it)->state;
worklist.push_back(*it);
}
}
} else {
if (isNotEnqueued(processed, zeroSuccessor, level-1)) {
worklist.push_back(zeroSuccessor);
}
}
}
}
#ifdef USE_STATECACHE
StateCache.storeIn(macroState, true, level);
#endif
return true;
}
}