本文整理汇总了C++中Link::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::erase方法的具体用法?C++ Link::erase怎么用?C++ Link::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main () {
Link* norse_gods = new Link("Thor");
norse_gods = norse_gods->insert(new Link("Odin"));
norse_gods = norse_gods->insert(new Link("Zeus"));
norse_gods = norse_gods->insert(new Link("Freia"));
Link* greek_gods = new Link("Hera");
greek_gods = greek_gods->insert(new Link("Athena"));
greek_gods = greek_gods->insert(new Link("Mars"));
greek_gods = greek_gods->insert(new Link("Poseidon"));
Link* g = greek_gods->find("Mars");
if (g) g->value = "Ares";
Link* n = norse_gods->find("Zeus");
if (n == norse_gods) norse_gods = n->next();
n->erase();
greek_gods = greek_gods->insert(n);
print_all(norse_gods);
cout << "======================" << endl;
print_all(greek_gods);
keep_window_open();
}
示例2: main
int main()
{
Link* norse_gods = new Link("Thor");
norse_gods = norse_gods->insert(new Link("Odin"));
norse_gods = norse_gods->insert(new Link("Zeus"));
norse_gods = norse_gods->insert(new Link("Freia"));
Link* greek_gods = new Link("Hera");
greek_gods = greek_gods->insert(new Link("Athena"));
greek_gods = greek_gods->insert(new Link("Mars"));
greek_gods = greek_gods->insert(new Link("Poseidon"));
Link* p = greek_gods->find("Mars");
if (p) p->value = "Ares";
// Move Zeus into his correct Pantheon:
{
Link* p = norse_gods->find("Zeus");
if (p) {
if (p==norse_gods)
norse_gods = p->next();
p->erase();
greek_gods = greek_gods->insert(p);
}
}
norse_gods->add(new Link("loki"));
// Finally, let's print out those lists:
print_all(norse_gods);
cout<<"\n";
norse_gods=norse_gods->advance(2); // test advance
print_all(norse_gods);
cout<<"\n";
print_all(greek_gods);
cout<<"\n";
cout<<greek_gods->node_count()<<endl; // test node count
Link* god_list=new Link("Apollo");
god_list=god_list->add(new Link("Aphrodite"));
god_list=god_list->add(new Link("Artemis"));
god_list=god_list->add(new Link("Hades"));
god_list=god_list->first();
print_all(god_list);
cout<<endl;
keep_window_open();
}