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


C++ Tuple::getElement方法代码示例

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


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

示例1: run

void BoltRankProtocol::run()
{
	int counter = 0;

	std::size_t connections = 0;
	std::string protocol = "";

	while(!killRunThread)
	{
		tupleQueueLock.lock();
		if ( !tupleQueue.empty() )
		{
			Tuple tuple = tupleQueue.front();
			tupleQueue.pop_front();
			tupleQueueLock.unlock();

			if (tuple.getNumElements() == 0)
			{
				continue;
			}

			if ( atoi(tuple.getElement(1).c_str()) > connections)
			{
				connections = atoi(tuple.getElement(1).c_str());
				protocol = tuple.getElement(0);

				std::cout << "Most visited: " << tuple.getSingleStringComa() << std::endl;
			}
		}
		else
		{
			tupleQueueLock.unlock();
		}
	}
}
开发者ID:shzhang1,项目名称:Crane,代码行数:35,代码来源:BoltRankProtocol.cpp

示例2: run

void BoltFilterFemale::run()
{
	int counter = 0;
	std::cout << "running female stasl" << std::endl;
	while(!killRunThread)
	{
		tupleQueueLock.lock();
		if ( !tupleQueue.empty() )
		{
			Tuple tuple = tupleQueue.front();
			tupleQueue.pop_front();
			tupleQueueLock.unlock();

			if (tuple.getElement(1) == "female" ) 
			{
				++counter;
				if (counter % 100 == 0)
				{
					std::cout << "Females: " << counter << std::endl;
				}
			}
		}
		else
		{
			tupleQueueLock.unlock();
		}
	}
}
开发者ID:XueweiKent,项目名称:Crane,代码行数:28,代码来源:BoltFilterFemale.cpp

示例3: run

void BoltSumBytes::run()
{
	int counter = 0;
	std::unordered_map<std::string,unsigned int> protocolMap;

	while(!killRunThread)
	{
		tupleQueueLock.lock();
		if ( !tupleQueue.empty() )
		{
			Tuple tuple = tupleQueue.front();
			tupleQueue.pop_front();
			tupleQueueLock.unlock();

			if(tuple.getNumElements() != 3)
			{
				continue;
			}

			std::string protocol = tuple.getElement(0);
			unsigned int sent = atoi(tuple.getElement(1).c_str());
			unsigned int recv = atoi(tuple.getElement(2).c_str());

			unsigned int sum = protocolMap[protocol];
			sum = sum + sent + recv;

			protocolMap[protocol] = sum;
			std::stringstream ss;
			ss << protocol << std::endl;
			ss << protocolMap[protocol] << std::endl;
			Tuple newTuple(ss.str());

			std::cout << newTuple.getSingleStringComa() << std::endl;
			emit(newTuple);

		}
		else
		{
			tupleQueueLock.unlock();
		}
	}
}
开发者ID:XueweiKent,项目名称:Crane,代码行数:42,代码来源:BoltSumBytes.cpp


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