本文整理汇总了C++中StringTable::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ StringTable::begin方法的具体用法?C++ StringTable::begin怎么用?C++ StringTable::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTable
的用法示例。
在下文中一共展示了StringTable::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StringValue
//---------------------------------------------------------------------------
const char* StringValue( const unsigned int stringID )
{
const char* errorValue = "empty!";
StringTable::iterator iter;
for ( iter = s_theStringTable.begin(); iter != s_theStringTable.end(); ++ iter )
{
if ( iter->second.m_id == stringID ) return iter->second.m_originalString.c_str();
}
return errorValue;
}
示例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());
}
示例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;
}
}
示例4: WriteStrings
bool WriteStrings(ostream& out,
const string& header,
StringTable& strings,
bool escape)
{
out << "[" << header << "]" << std::endl;
for (StringTable::iterator iter = strings.begin();
iter != strings.end();
iter++) {
out << iter->first << "=";
if (escape)
out << Escape(iter->second);
else
out << iter->second;
out << std::endl;
}
return true;
}
示例5: 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());
}
}
}