本文整理汇总了C++中SearchData::addAll方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchData::addAll方法的具体用法?C++ SearchData::addAll怎么用?C++ SearchData::addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchData
的用法示例。
在下文中一共展示了SearchData::addAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doSearch
void SearchOperation::doSearch( SearchData& searchData, qint64 initialLine )
{
const qint64 nbSourceLines = sourceLogData_->getNbLine();
int maxLength = 0;
int nbMatches = searchData.getNbMatches();
SearchResultArray currentList = SearchResultArray();
// Ensure no re-alloc will be done
currentList.reserve( nbLinesInChunk );
LOG(logDEBUG) << "Searching from line " << initialLine << " to " << nbSourceLines;
if (initialLine < startLine_) {
initialLine = startLine_;
}
const qint64 endLine = qMin(nbSourceLines, endLine_);
for ( qint64 i = initialLine; i < endLine; i += nbLinesInChunk ) {
if ( *interruptRequested_ )
break;
const int percentage = ( i - initialLine ) * 100 / ( endLine - initialLine );
emit searchProgressed( nbMatches, percentage );
const QStringList lines = sourceLogData_->getLines( i,
qMin( nbLinesInChunk, (int) ( endLine - i ) ) );
LOG(logDEBUG) << "Chunk starting at " << i <<
", " << lines.size() << " lines read.";
int j = 0;
for ( ; j < lines.size(); j++ ) {
if ( regexp_.match( lines[j] ).hasMatch() ) {
// FIXME: increase perf by removing temporary
const int length = sourceLogData_->getExpandedLineString(i+j).length();
if ( length > maxLength )
maxLength = length;
currentList.push_back( MatchingLine( i+j ) );
nbMatches++;
}
}
// After each block, copy the data to shared data
// and update the client
searchData.addAll( maxLength, currentList, i+j );
currentList.clear();
}
emit searchProgressed( nbMatches, 100 );
}
示例2: doSearch
//.........这里部分代码省略.........
matchers.emplace_back( makeMatcher( i ) );
}
auto processMatches = QtConcurrent::run( localThreadPool.get(), [&]() {
auto cToken = moodycamel::ConsumerToken{ processMatchQueue };
size_t matchersDone = 0;
int reportedPercentage = 0;
auto reportedMatches = nbMatches;
LinesCount totalProcessedLines = 0_lcount;
const auto totalLines = endLine - initialLine;
for ( ;; ) {
PartialSearchResults matchResults;
processMatchQueue.wait_dequeue( cToken, matchResults );
LOG( logDEBUG ) << "Combining match results from " << matchResults.chunkStart;
if ( matchResults.processedLines.get() ) {
maxLength = qMax( maxLength, matchResults.maxLength );
nbMatches += LinesCount(
static_cast<LinesCount::UnderlyingType>( matchResults.matchingLines.size() ) );
const auto processedLines = LinesCount{ matchResults.chunkStart.get()
+ matchResults.processedLines.get() };
totalProcessedLines += matchResults.processedLines;
// After each block, copy the data to shared data
// and update the client
searchData.addAll( maxLength, matchResults.matchingLines, processedLines );
LOG( logDEBUG ) << "done Searching chunk starting at " << matchResults.chunkStart
<< ", " << matchResults.processedLines << " lines read.";
blocksDone.release( matchResults.processedLines.get() );
}
else {
matchersDone++;
}
const int percentage
= static_cast<int>( std::floor( 100.f * ( totalProcessedLines ).get() / totalLines.get() ) );
if ( percentage > reportedPercentage || nbMatches > reportedMatches ) {
emit searchProgressed( nbMatches, std::min( 99, percentage ), initialLine );
reportedPercentage = percentage;
reportedMatches = nbMatches;
}
if ( matchersDone == matchers.size() ) {
searchCompleted.release();
return;
}
}
} );
auto pToken = moodycamel::ProducerToken{ searchBlockQueue };
blocksDone.release( nbLinesInChunk.get() * ( static_cast<uint32_t>( matchers.size() ) + 1 ) );