当前位置: 首页>>代码示例>>C++>>正文


C++ Automaton::IsStateFinal方法代码示例

本文整理汇总了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;
	}

}
开发者ID:inmathwetrust,项目名称:dWiNA,代码行数:73,代码来源:decision_procedures.cpp


注:本文中的Automaton::IsStateFinal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。