本文整理汇总了C++中Search::search方法的典型用法代码示例。如果您正苦于以下问题:C++ Search::search方法的具体用法?C++ Search::search怎么用?C++ Search::search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Parser p;
IndexReader in;
in.genIndexFromFile();
Search s;
string query;
while (getline(cin,query)) {
Query* q=p.parse(query);
//cout<<"------"<<endl;
//cout<<q->sign<<" "<<q->token<<endl;
/*for(int i=0;i<q->size();i++)
{
Query* s=q->get(i);
//cout<<s->sign<<" "<<s->token<<endl;
for(int j=0;j<s->size();j++)
{
Query* p=s->get(j);
// cout<<p->sign<<" "<<p->token<<endl;
}
}*/
vector<vector<string> > l;
s.search(q,in,l);
s.show(q,in,l);
delete q;
}
}
示例2: getExtractionData
bool getExtractionData(const Game *g, Search &search, ExtractMap &map) {
SearchMap searchMap;
const int *needList = getNeedList(g);
if (!needList) {
fprintf(stderr, "ERROR: No entry need list available\n");
return false;
}
if (!setupSearch(g, needList, search, searchMap))
return false;
// Process the data search
Search::ResultList results;
search.search(results);
if (results.empty()) {
fprintf(stderr, "ERROR: Couldn't find any required data\n");
return false;
}
ExtractMap temporaryExtractMap;
for (const int *entry = needList; *entry != -1; ++entry) {
typedef std::pair<SearchMap::const_iterator, SearchMap::const_iterator> KeyRange;
KeyRange idRange = searchMap.equal_range(*entry);
for (Search::ResultList::const_iterator i = results.begin(); i != results.end(); ++i) {
for (SearchMap::const_iterator j = idRange.first; j != idRange.second; ++j) {
if (j->second.hint == i->data)
temporaryExtractMap.insert(ExtractMapEntry(*entry, ExtractData(j->second, i->offset)));
}
}
}
// Free up some memory
results.clear();
searchMap.clear();
bool result = true;
for (const int *entry = needList; *entry != -1; ++entry) {
MatchList possibleMatches = filterPlatformMatches(g, temporaryExtractMap.equal_range(*entry));
if (possibleMatches.empty()) {
fprintf(stderr, "ERROR: No entry found for id %d/%s\n", *entry, getIdString(*entry));
result = false;
continue;
}
if (isLangSpecific(*entry)) {
for (int i = 0; i < 3; ++i) {
if (g->lang[i] == -1)
continue;
MatchList langMatches = filterLanguageMatches(g->lang[i], possibleMatches);
MatchList::const_iterator bestMatch = filterOutBestMatch(langMatches);
if (bestMatch == langMatches.end()) {
// TODO: Add nice language name to output message.
fprintf(stderr, "ERROR: No entry found for id %d/%s for language %d\n", *entry, getIdString(*entry), g->lang[i]);
result = false;
continue;
}
#ifdef DEBUG_EXTRACTION_TABLES
if (((*bestMatch)->second.desc.platform != kPlatformUnknown && (*bestMatch)->second.desc.platform != g->platform))
printf("%s: %.8X %.8X %d %d\n", getIdString(*entry), (*bestMatch)->second.desc.hint.size, (*bestMatch)->second.desc.hint.byteSum, (*bestMatch)->second.desc.lang, (*bestMatch)->second.desc.platform);
#endif
map.insert(**bestMatch);
}
} else {
MatchList::const_iterator bestMatch = filterOutBestMatch(possibleMatches);
if (bestMatch == possibleMatches.end()) {
fprintf(stderr, "ERROR: No entry found for id %d/%s\n", *entry, getIdString(*entry));
result = false;
continue;
}
#ifdef DEBUG_EXTRACTION_TABLES
if (((*bestMatch)->second.desc.platform != kPlatformUnknown && (*bestMatch)->second.desc.platform != g->platform))
printf("%s: %.8X %.8X %d %d\n", getIdString(*entry), (*bestMatch)->second.desc.hint.size, (*bestMatch)->second.desc.hint.byteSum, (*bestMatch)->second.desc.lang, (*bestMatch)->second.desc.platform);
#endif
map.insert(**bestMatch);
}
}
return result;
}