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


C++ BloomFilter::SubText方法代码示例

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


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

示例1: main

int main(void)
{
	vector<long long> BloomDataAddTime;
	vector<long long> BloomDataSubTime;
	vector<unsigned long long> BloomDataSize;
	
	std::cout << "ブルームフィルタテスト" << std::endl;
	std::cout << "測定開始" << std::endl;
	for (int count = 1; count <= 100; count++)
	{
		BloomFilter BF;
		auto Start = std::chrono::system_clock::now();
		for (int i = 0; i < 100; i++)
		{
			BF.AddText(to_string(i));
			std::cout << BF.GetFilter() << std::endl;
		}
		auto End = std::chrono::system_clock::now();
		auto Time = End - Start;
		auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(Time).count();
		BloomDataAddTime.push_back(ms);
		BloomDataSize.push_back(sizeof(BF));

		Start = std::chrono::system_clock::now();
		for (int i = 0; i < 100; i++)
		{
			BF.SubText(to_string(i));
			std::cout << BF.GetFilter() << std::endl;
		}
		End = std::chrono::system_clock::now();
		Time = End - Start;
		ms = std::chrono::duration_cast<std::chrono::milliseconds>(Time).count();
		BloomDataSubTime.push_back(ms);
	}
	std::cout << "測定終了" << std::endl;

	std::cout << "データ追加" << std::endl;
	std::sort(BloomDataAddTime.begin(), BloomDataAddTime.end());

	std::cout << "最低値" << std::endl;
	std::cout << "AddTime : "<< BloomDataAddTime.front() << std::endl;
	std::cout << "AddSize : " << BloomDataSize.front() << std::endl;

	std::cout << "最高値" << std::endl;
	std::cout << "AddTime : " << BloomDataAddTime.back() << std::endl;
	std::cout << "AddSize : " << BloomDataSize.back() << std::endl;

	std::cout << "中央値" << std::endl;
	if (BloomDataAddTime.size() % 2 == 0)
	{
		int pos = BloomDataAddTime.size() / 2;
		std::cout << "AddTime : " << (BloomDataAddTime[pos] + BloomDataAddTime[pos + 1]) / 2 << std::endl;
	}
	else
	{
		std::cout << "AddTime : " << BloomDataAddTime[(int)(BloomDataAddTime.size() / 2+1)]<< std::endl;
	}
	if (BloomDataSize.size() % 2 == 0)
	{
		int pos = BloomDataSize.size() / 2;
		std::cout << "AddSize : " << (BloomDataSize[pos] + BloomDataSize[pos + 1]) / 2 << std::endl;
	}
	else
	{
		std::cout << "AddSize : " << BloomDataSize[(int) (BloomDataSize.size() / 2 + 1)] << std::endl;
	}

	std::cout << "平均値" << std::endl;
	long long Average = 0;
	for (auto Time : BloomDataAddTime)
	{
		Average += Time;
	}
	std::cout << "AddTime : " << (float) Average / BloomDataAddTime.size() << std::endl;
	Average = 0;
	for (auto Time : BloomDataSize)
	{
		Average += Time;
	}
	
	std::cout << "データサイズ" << std::endl;
	std::sort(BloomDataSize.begin(), BloomDataSize.end());
	std::cout << "AddSize : " << (float) Average / BloomDataSize.size() << std::endl;

	std::cout << "データ削除" << std::endl;
	std::sort(BloomDataSubTime.begin(), BloomDataSubTime.end());

	std::cout << "最低値" << std::endl;
	std::cout << "SubTime : " << BloomDataSubTime.front() << std::endl;

	std::cout << "最高値" << std::endl;
	std::cout << "SubTime : " << BloomDataSubTime.back() << std::endl;

	std::cout << "中央値" << std::endl;
	if (BloomDataSubTime.size() % 2 == 0)
	{
		int pos = BloomDataSubTime.size() / 2;
		std::cout << "SubTime : " << (BloomDataSubTime[pos] + BloomDataSubTime[pos + 1]) / 2 << std::endl;
	}
	else
//.........这里部分代码省略.........
开发者ID:EXPEXE,项目名称:BloomCountingFilter,代码行数:101,代码来源:Main.cpp


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