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


C++ StringTable::size方法代码示例

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


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

示例1: CountOccurrences

static void CountOccurrences(int nthreads) {
    StringTable table;

    tick_count t0 = tick_count::now();
    parallel_for( blocked_range<mystring*>( Data, Data+N, 1000 ), Tally(table) );
    tick_count t1 = tick_count::now();

    int n = 0;
    for( StringTable::iterator i=table.begin(); i!=table.end(); ++i ) {
        if( Verbose && nthreads )
            printf("%s %d\n",i->first.c_str(),i->second);
        n += i->second;
    }

    if (is_number_of_threads_set) {
        printf("threads = %d  total = %d  unique = %u  time = %g\n", nthreads, n, unsigned(table.size()), (t1-t0).seconds());
    } else {
        if ( nthreads == 1 ) {
            printf("serial run   total = %d  unique = %u  time = %g\n", n, unsigned(table.size()), (t1-t0).seconds());
        } else {
            printf("parallel run total = %d  unique = %u  time = %g\n", n, unsigned(table.size()), (t1-t0).seconds());
        }
    }
}
开发者ID:GDXN,项目名称:fitsliberator,代码行数:24,代码来源:count_strings.cpp

示例2: CountOccurrences

static void CountOccurrences(int nthreads) {
    StringTable table;

    tick_count t0 = tick_count::now();
    parallel_for( blocked_range<MyString*>( Data, Data+N, 1000 ), Tally(table) );
    tick_count t1 = tick_count::now();

    int n = 0;
    for( StringTable::iterator i=table.begin(); i!=table.end(); ++i ) {
        if( verbose && nthreads )
            printf("%s %d\n",i->first.c_str(),i->second);
        n += i->second;
    }

    if ( !silent ) printf("total = %d  unique = %u  time = %g\n", n, unsigned(table.size()), (t1-t0).seconds());
}
开发者ID:Klaim,项目名称:aos-cpp-dependencies,代码行数:16,代码来源:count_strings.cpp

示例3: Save

    void Save(const char* filename)
    {
        const std::string header("String #");
        const std::string header_next(" is ");
        const char splitter = '~';

        if(_origin.empty())
            return;

        std::ofstream  fin(filename);

        fin << "// Total:" << _origin.size() << std::endl;
        StringTable::iterator itr = _origin.begin();
        for(;itr!=_origin.end();itr++)
        {
            fin << header << itr->first << header_next << splitter
                << itr->second << splitter << std::endl;
        }
    }
开发者ID:fantasydr,项目名称:nwn2dev,代码行数:19,代码来源:UpdateModTemplates.cpp

示例4: readItems

bool ItemReader::readItems(std::map<std::string, ItemBean>& itemMap) const
{
	itemMap.clear();
	wstring contents = getFileContentsWide(g_resourceManager->getFilename(ResourceID::Items));
	if (contents.empty())
	{
		return false;
	}
	StringTable tab;
	parseCsv((wchar_t *)contents.c_str(), tab);
	if (tab.size() == 0 || tab[0].size() != COLUMN_COUNT)
	{
		g_logger->logError("ItemReader", "Error in item file, incorrect number of columns or no rows");
		return false;
	}
	
	int lineNr = 0;
	for (auto &row : tab)
	{
		lineNr++;
		if (lineNr == 1)
		{
			// we skip the first row as it is a description of the colums (title row)
			continue;
		}
		ItemBean item = DEFAULT_ITEM;
		vector<string> columns;
		for (auto &col : row)
		{
			columns.push_back(string(col.begin(), col.end()));
		}

		while (columns.size() < COLUMN_COUNT)
		{
			columns.push_back("");
		}

		if (columns.size() != COLUMN_COUNT)
		{
			g_logger->logError("ItemReader", "Error in item file, incorrect number of columns");
			return false;
		}

		// <<<<<<<< PARSE >>>>>>>>>

		// item id
		item.id = columns[0];
		// item description
		item.description = columns[1];
		// item type
		item.type = static_cast<ItemType>(atoi(columns[2].c_str()));
		// icon texture location
		if (!columns[3].empty() && columns[3].find(",") != string::npos && columns[3].find(",") + 1 < columns[3].size())
		{
			item.iconTextureLocation.x = atoi(columns[3].c_str());
			item.iconTextureLocation.y = atoi(columns[3].substr(columns[3].find(",") + 1).c_str());
		}
		// gold value
		item.goldValue = atoi(columns[4].c_str());
		// attributes
		item.attributes.maxHealthPoints = atoi(columns[5].c_str());
		item.attributes.healthRegenerationPerS = atoi(columns[6].c_str());
		item.attributes.haste = atoi(columns[7].c_str());
		item.attributes.critical = atoi(columns[8].c_str());
		item.attributes.damagePhysical = atoi(columns[9].c_str());
		item.attributes.damageFire = atoi(columns[10].c_str());
		item.attributes.damageIce = atoi(columns[11].c_str());
		item.attributes.damageShadow = atoi(columns[12].c_str());
		item.attributes.damageLight = atoi(columns[13].c_str());
		item.attributes.resistancePhysical = atoi(columns[14].c_str());
		item.attributes.resistanceFire = atoi(columns[15].c_str());
		item.attributes.resistanceIce = atoi(columns[16].c_str());
		item.attributes.resistanceShadow = atoi(columns[17].c_str());
		item.attributes.resistanceLight = atoi(columns[18].c_str());
		// food duration
		item.foodDuration = sf::seconds(static_cast<float>(atoi(columns[19].c_str())));
		// sprite offset
		if (!columns[20].empty() && columns[20].find(",") != string::npos && columns[20].find(",") + 1 < columns[20].size())
		{
			item.spriteOffset.x = static_cast<float>(atoi(columns[20].c_str()));
			item.spriteOffset.y = static_cast<float>(atoi(columns[20].substr(columns[20].find(",") + 1).c_str()));
		}
		// level item bounding box
		if (!columns[21].empty())
		{
			std::stringstream ss(columns[21]);
			int i;
			vector<float> boundingBoxValues;
			while (ss >> i)
			{
				boundingBoxValues.push_back(static_cast<float>(i));

				if (ss.peek() == ',' || ss.peek() == ' ')
					ss.ignore();
			}
			if (boundingBoxValues.size() != 2)
			{
				g_logger->logError("ItemReader", "Level Item Bounding box could not be parsed!");
				return false;
			}
//.........这里部分代码省略.........
开发者ID:G-GFFD,项目名称:Cendric2,代码行数:101,代码来源:ItemReader.cpp


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