本文整理汇总了C++中Dlist::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Dlist::Empty方法的具体用法?C++ Dlist::Empty怎么用?C++ Dlist::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dlist
的用法示例。
在下文中一共展示了Dlist::Empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prompt
main(int argc, char **argv)
{
map <string, Dnode *> words;
Dlist *l;
Dnode *n;
vector <string> sv;
string s;
string p;
if (argc != 2) {
cerr << "usage: list_editor prompt(- for none)\n";
exit(1);
}
l = new Dlist;
p = argv[1];
while(1) {
if (p != "-") {
printf("%s ", p.c_str());
fflush(stdout);
}
if (!getline(cin, s)) exit(0);
sv = StoSVec(s);
if (sv.size() == 0 || sv[0][0] == '#') {
} else if (sv[0] == "CLEAR") {
if (sv.size() != 1) {
printf("CLEAR takes no arguments.\n");
} else {
delete l;
words.clear();
l = new Dlist;
}
} else if (sv[0] == "EMPTY") {
if (sv.size() != 1) {
printf("EMPTY takes no arguments.\n");
} else {
cout << ((l->Empty()) ? "Yes" : "No") << endl;
}
} else if (sv[0] == "SIZE") {
if (sv.size() != 1) {
printf("SIZE takes no arguments.\n");
} else {
cout << l->Size() << endl;
}
} else if (sv[0] == "ERASE") {
if (sv.size() != 2) {
printf("ERASE word.\n");
} else {
if (words.find(sv[1]) == words.end()) {
cout << sv[1] << " is not on the list\n";
} else {
l->Erase(words[sv[1]]);
words.erase(words.find(sv[1]));
}
}
} else if (sv[0] == "INSERT_BEFORE") {
if (sv.size() != 3) {
printf("INSERT_BEFORE s1 s2.\n");
} else {
if (words.find(sv[1]) != words.end()) {
cout << sv[1] << " is already on the list\n";
} else if (words.find(sv[2]) == words.end()) {
cout << sv[2] << " is not on the list\n";
} else {
n = words[sv[2]];
l->Insert_Before(sv[1], n);
words[sv[1]] = n->blink;
}
}
} else if (sv[0] == "INSERT_AFTER") {
if (sv.size() != 3) {
printf("INSERT_AFTER s1 s2.\n");
} else {
if (words.find(sv[1]) != words.end()) {
cout << sv[1] << " is already on the list\n";
} else if (words.find(sv[2]) == words.end()) {
cout << sv[2] << " is not on the list\n";
} else {
n = words[sv[2]];
l->Insert_After(sv[1], n);
words[sv[1]] = n->flink;
}
}
} else if (sv[0] == "PUSH_BACK") {
if (sv.size() != 2) {
printf("PUSH_BACK word.\n");
} else {
if (words.find(sv[1]) != words.end()) {
cout << sv[1] << " is already on the list\n";
} else {
l->Push_Back(sv[1]);
words[sv[1]] = l->Rbegin();
}
}
} else if (sv[0] == "PUSH_FRONT") {
if (sv.size() != 2) {
printf("PUSH_FRONT word.\n");
} else {
//.........这里部分代码省略.........