本文整理汇总了C++中Index::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::clear方法的具体用法?C++ Index::clear怎么用?C++ Index::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static ArrayRef<ComboItem> interpolator_fill()
{
items.clear();
for(MPTWrap::Interpolator &interpolator : MPTWrap::get_interpolators())
{
items.append(interpolator.name, interpolator.value);
}
return { items.begin(), items.len() };
}
示例2: inFile
StressTest::StressTest(std::string filename) {
std::ifstream inFile(filename);
if(!inFile.is_open()) throw;
std::string line, opcode;
Index* index;
while(inFile.good()) {
line = opcode = "";
std::getline(inFile, line);
std::stringstream line_stream(line);
line_stream >> opcode;
if(opcode == "ST") { // start timer
if(timer_running) std::cout << "Timer already running." << std::endl;
else {
start = std::chrono::system_clock::now();
timer_running = true;
std::cout << "Timer started." << std::endl;
}
}
else if(opcode == "EN") { // end timer, output time between
if(!timer_running) std::cout << "Timer not running." << std::endl;
else {
stop = std::chrono::system_clock::now();
auto diff = stop - start;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(diff).count();
auto s = std::chrono::duration_cast<std::chrono::seconds>(diff).count();
std::cout << "Timer stopped: " << (int) ms/1000 << " seconds, " << (int)ms%1000 << " milliseconds" << std::endl;
timer_running = false;
}
}
else if(opcode == "CL") { // close/save index
if(!index_open) std::cout << "No index open. Can't save/close." << std::endl;
else {
index->save();
delete index;
index_open = false;
index_changed = false;
std::cout << "Index saved and closed." << std::endl;
}
}
else if(opcode == "OP") { // open index
if(index_open) std::cout << "Index already open. Can't open another." << std::endl;
else {
std::string index_filename;
line_stream >> index_filename;
if(index_type == HASHTABLE) index = new STLHashTableIndex(index_filename);
else if(index_type == AVLTREE) index = new AVLTreeIndex(index_filename);
else throw; // something wrong happened
index->load();
index_open = true;
index_changed = false;
std::cout << "Index successfully loaded." << std::endl;
}
}
else if(opcode == "RM") { // clear index
if(!index_open) std::cout << "No index open. Can't clear." << std::endl;
else {
index->clear();
std::cout << "Index cleared." << std::endl;
index_changed = true;
}
}
else if(opcode == "LD") { // load file into index
if(!index_open) std::cout << "No index open to add to" << std::endl;
else {
std::string filename;
line_stream >> filename;
XMLParser parser(filename, index);
parser.threadedParseAndProcess();
std::cout << filename <<" loaded into index." << std::endl;
index_changed = true;
}
}
else if(opcode == "QU") { // run query on index