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


C++ States::insert方法代码示例

本文整理汇总了C++中States::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ States::insert方法的具体用法?C++ States::insert怎么用?C++ States::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在States的用法示例。


在下文中一共展示了States::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: expand

// 所有从from通过一次ch到达的NFA状态
// 这里有-1,表示上次fill只有一个最终状态,即-1
static States expand(const std::vector<NFATran>& trans, const States& from, char ch) {
	States to;
	for (States::const_iterator it = from.begin();
			it != from.end(); ++it) {
		int s = *it;
		if (s == -1) {
			to.clear();
			to.insert(-1);
			break;
		}

		const NFATran& tran = trans[s];
		NFATran::const_iterator tit = tran.find(ch);
		if (tit == tran.end()) {
			continue;
		}

		const States& next = tit->second;
		for (States::const_iterator nit = next.begin();
			nit != next.end(); ++nit) {
			to.insert(*nit);
		}
	}

	return to;
}
开发者ID:LelouchHe,项目名称:mpl,代码行数:28,代码来源:dfa_converter.cpp

示例2: fill

// 所有能从from通过EPSILON能达到的NFA状态(包括from)
static States fill(const std::vector<NFATran>& trans, const States& last, const States& from, bool* is_last) {
	std::queue<int> q;
	for (States::const_iterator it = from.begin();
			it != from.end(); ++it) {
		q.push(*it);
	}

	// ends表示终点(即最终状态),要判断这次转移是否只有-1
	States ends;
	States to;
	while (!q.empty()) {
		int s = q.front();
		q.pop();

		to.insert(s);
		if (last.find(s) != last.end()) {
			*is_last = true;
		}

		if (s == -1) {
			ends.insert(-1);
			continue;
		}

		const NFATran& tran = trans[s];
		NFATran::const_iterator it = tran.find(EPSILON);
		if (it == tran.end()) {
			ends.insert(s);
			continue;
		}

		const States& next = it->second;
		for (States::const_iterator nit = next.begin();
				nit != next.end(); ++nit) {
			if (to.find(*nit) == to.end()) {
				q.push(*nit);
			}
		}
	}

	if (ends.find(-1) == ends.end() || ends.size() > 1) {
		to.erase(-1);
	} else {
		to.clear();
		to.insert(-1);
	}

	return to;
}
开发者ID:LelouchHe,项目名称:mpl,代码行数:50,代码来源:dfa_converter.cpp

示例3: build

bool DFAConverter::build(int start, int last,
		const std::vector<NFATran>& trans,
		const std::map<size_t, Tag>& tags) {
	States lasts;
	lasts.insert(last);

	return build(start, lasts, trans, tags);
}
开发者ID:LelouchHe,项目名称:mpl,代码行数:8,代码来源:dfa_converter.cpp

示例4:

 /**
  * 
  * @brief returns all targets that correspond with the given source 
  *
  * @param - source: the source whose targets to look for
  * @return the set of all targets that correspond with the given source 
  *
  */
 const TransitionStorage::States TransitionStorage::getTargets( State source ) const
 {
   States targets;
   const Info::Internals & src = T_info.fromTrans(source);
   for( Info::InternalIterator it = src.begin(); it != src.end(); it++ )
   {
     targets.insert(getTarget(*it));
   }
   return targets;
 }
开发者ID:pohmann,项目名称:WALi-OpenNWA,代码行数:18,代码来源:TransitionStorage.cpp

示例5: process

//Return a queue of the calculated transition pairs, based on the non-deterministic
//  finite automaton, initial state, and queue of inputs; each pair in the returned
//  queue is of the form: input, set of new states.
//The first pair contains "" as the input and the initial state.
//If any input i is illegal (does not lead to any state in the non-deterministic finite
//  automaton), ignore it.
TransitionsQueue process(const NDFA& ndfa, std::string state, const InputsQueue& inputs) {

	TransitionsQueue answer;
	States initialState;

	initialState.insert(state);
	answer.enqueue(Transitions("", (initialState)));

	for (auto x : inputs)
	{
		if((ndfa[state].has_key(x)))
		{
			answer.enqueue(Transitions(x, ndfa[state][x]));
			//std::cout << "answer after enqueue: " << answer << std::endl;
		}
		else
		{
			break;
		}
	}
	return answer;
}
开发者ID:falmatam,项目名称:DataStructure,代码行数:28,代码来源:ndfa.cpp


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