本文整理汇总了C++中SList::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::remove方法的具体用法?C++ SList::remove怎么用?C++ SList::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
SList<int> intList;
POSITION p1=intList.push_back(1);
POSITION p2=intList.push_back(2);
POSITION p3=intList.push_back(3);
POSITION p4=intList.push_back(4);
POSITION p5=intList.push_back(5);
for(POSITION p=intList.start(); p != 0 ;p=intList.next(p)) //A != operátort end()-re nem tudta értelmezni így helyette 0-t írtam
{
cout<<intList.getAt(p)<<endl;
}
cout<<"Remove: "<<intList.remove(p2)<<endl;
cout<<"Remove: "<<intList.remove(p1)<<endl;
cout<<"Remove: "<<intList.remove(p5)<<endl;
cout<<"Remove: "<<intList.remove(p3)<<endl;
intList.insert_after(p4,10);
intList.insert_after(p4,11);
for(POSITION p2=intList.start();p2 != 0; p2= intList.next(p2)) //A != operátort end()-re nem tudta értelmezni így helyette 0-t írtam
{
cout<<intList.getAt(p2)<<endl;
}
cout << "iteratorral:\n";
for(SList<int>::iterator it = intList.begin(); it != intList.end(); ++it)
cout << *it << " ";
cout << endl;
SList<int> intList_2 = intList.reverse(); //A reverse függvény értelmetlen lenne másoló kontruktor használata nélkül
//A konstokat pedig iterátor használat céljából távolítottuk el.
cout << "A forditott lista: ";
for(SList<int>::iterator it = intList_2.begin(); it != intList_2.end(); ++it)
cout << *it << " ";
cout << endl;
SList<int> intList_3 = intList.concatenate(intList_2); //A concatenate tesztelése
cout << "Az eredeti es a forditott lista osszefuzese: ";
for(SList<int>::iterator it = intList_3.begin(); it != intList_3.end(); ++it)
cout << *it << " ";
cout << endl;
getchar();
return 0;
}
示例2: main
int main()
{
SList<int> sl;
sl.insert_first(1);
sl.display();
sl.insert_last(2);
sl.display();
sl.insert_last(3);
sl.display();
sl.remove_last();
sl.display();
sl.remove_first();
sl.display();
cout << sl.find(2) << endl;
sl.insert(4, sl.find(2));
sl.display();
sl.remove(sl.find(4));
sl.display();
sl.remove_all();
return 0;
}
示例3: main
int main() {
SList<int> *intList = new SList<int>;
delete intList;
SList<string> facultyList;
facultyList.insert("unknown");
facultyList.insert("erdly");
facultyList.insert("sung");
facultyList.insert("olson");
facultyList.insert("zander");
facultyList.insert("berger");
facultyList.insert("cioch");
facultyList.insert("fukuda");
facultyList.insert("stiber");
facultyList.insert("jackels");
cout << "#faculty members: " << facultyList.size() << endl;
facultyList.show();
cout << endl;
cout << "deleting unknown" << endl;
facultyList.remove("unknown");
cout << "#faculty members: " << facultyList.size() << endl;
facultyList.show();
cout << endl;
cout << "finding stiber = " << facultyList.find("stiber") << endl;
cout << endl;
cout << "create another list" << endl;
SList<string> studentList = facultyList;
cout << "finding stiber = " << facultyList.find("stiber") << endl;
cout << "#faculty members: " << facultyList.size() << endl;
cout << endl;
cout << "cost of find = " << facultyList.getCost() << endl;
}