本文整理汇总了C++中SList::push_front方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::push_front方法的具体用法?C++ SList::push_front怎么用?C++ SList::push_front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::push_front方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void SwapTwoLists::run()
{
SList newList;
SList otherList;
std::string str1 = "foo";
std::string str2 = "bar";
std::string str3 = "baz";
std::string str4 = "far";
std::string str5 = "faz";
newList.push_front(str1);
newList.push_front(str2);
newList.push_front(str3);
otherList.push_front(str4);
otherList.push_front(str5);
newList.swap(otherList);
checkEquals(newList.front(), str5);
newList.pop_front();
checkEquals(newList.front(), str4);
checkEquals(otherList.front(), str3);
otherList.pop_front();
checkEquals(otherList.front(), str2);
otherList.pop_front();
checkEquals(otherList.front(), str1);
}
示例2: test_push_front
void test_push_front(Test* test)
{
std::string s("hello");
SList* list = new SList("hello","word");
list->push_front(s);
std::string act=list->get_first()->get_stringi();
test->equals(act,s);
delete list;
}
示例3: reverse
void SList::reverse() {
SList tmp;
Elem *tmp_elem = front;
while(tmp_elem) {
tmp.push_front(tmp_elem->get_contents());
tmp_elem = tmp_elem->next;
}
tmp.swap(*this);
}
示例4: testSList
void testSList()
{
SList list;
list.push_front("Alice");
list.push_front("Bob");
list.push_front("Copernicus");
for (SList::ConstIterator cit = list.begin(); cit != list.end(); ++cit) {
std::cout << *cit << std::endl;
}
std::cout << std::endl;
for (SList::Iterator it = list.begin(); it != list.end(); ++it) {
std::cout << *it << std::endl;
}
std::cout << std::endl;
}
示例5: 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;
}