本文整理汇总了C++中SList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::push_back方法的具体用法?C++ SList::push_back怎么用?C++ SList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::push_back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_iter
void test_iter(Test* test)
{
SList* list = new SList("hello","wordl");
list->push_back("hi");
list->push_back("why");
for(SList_iterator it = list->begin();it!=list->end();it++)
std::cout<<(*it).get_stringi()<<endl;
delete list;
}
示例2: test_reverse
void test_reverse(Test* test)
{
SList* list = new SList("hello","wordl");
list->push_back("hi");
list->push_back("why");
(*list).reverse();
delete list;
}
示例3: 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;
}
示例4: main
int main()
{
/* string list */
SList<string> strlist;
strlist.push_back("syed");
strlist.push_back("ahsan");
strlist.push_front("ishtiaque");
strlist.print();
cout << strlist.is_present("ahsan") << endl;
strlist.push_back("ahsan");
strlist.print();
strlist.delete_first("ahsan");
strlist.print();
strlist.push_back("ahsan");
strlist.print();
strlist.delete_all("ahsan");
strlist.print();
return 0;
}