本文整理汇总了C++中Entries::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ Entries::rend方法的具体用法?C++ Entries::rend怎么用?C++ Entries::rend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entries
的用法示例。
在下文中一共展示了Entries::rend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
if(argc < 3) {
printf("Usage whateveryoujusttyped.exe readFileName writeFileName\n");
return -1;
}
const char* readFilename = argv[1];
const char* writeFilename = argv[2];
std::ifstream readFile(readFilename);
if(!readFile.is_open()) {
printf("Couldn't open %s for reading\n", readFilename);
return -1;
}
std::ofstream writeFile(writeFilename);
if(!writeFile.is_open()) {
printf("Couldn't open %s for writing\n", writeFilename);
return -1;
}
typedef std::list<std::string> Entries;
Entries entries;
std::string currentEntry;
std::string line;
while(std::getline(readFile, line)) {
if(strstr(line.c_str(), "===") != NULL) {
if(!currentEntry.empty()) {
entries.push_back(currentEntry);
}
currentEntry.clear();
}
currentEntry += line;
currentEntry += "\n";
}
if(!currentEntry.empty()) {
entries.push_back(currentEntry);
}
readFile.close();
for(auto entryIt = entries.rbegin();
entryIt != entries.rend();
++entryIt) {
writeFile << (*entryIt);
}
writeFile.close();
return 0;
}
示例2: entry
Entry * entry(Tracked const * const r) {
for (Entries::reverse_iterator i(entries.rbegin()); i != entries.rend(); ++i) if (i->p == r) return &*i;
return 0;
}