当前位置: 首页>>代码示例>>C++>>正文


C++ SList::push_front方法代码示例

本文整理汇总了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);
}
开发者ID:samitheberber,项目名称:SList,代码行数:26,代码来源:creation_tests.cpp

示例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;
}
开发者ID:anttitup,项目名称:c--harkka,代码行数:9,代码来源:Main.cpp

示例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);
 }
开发者ID:arrimurri,项目名称:SList,代码行数:9,代码来源:slist.cpp

示例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;
}
开发者ID:defagos,项目名称:cppDesignBook,代码行数:18,代码来源:testSList.cpp

示例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;
}
开发者ID:syedahsan,项目名称:codes,代码行数:21,代码来源:main.cpp


注:本文中的SList::push_front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。