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


C++ DoublyLinkedList::pushBack方法代码示例

本文整理汇总了C++中DoublyLinkedList::pushBack方法的典型用法代码示例。如果您正苦于以下问题:C++ DoublyLinkedList::pushBack方法的具体用法?C++ DoublyLinkedList::pushBack怎么用?C++ DoublyLinkedList::pushBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoublyLinkedList的用法示例。


在下文中一共展示了DoublyLinkedList::pushBack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	if(runTests())
	{
		DoublyLinkedList<int> list;
		unsigned int numberOfPeople;
		unsigned int currentIndex;

		list.clear();
		for (unsigned int count = 0; count < numberOfPeople; ++count)
		{
			list.pushBack(count + 1);
		}

		while(numberOfPeople > 1)
		{
			for (unsigned int skip = 0; skip < 33; ++skip)
			{
				currentIndex++;
				if( currentIndex > list.size() )
					currentIndex = 1;
			}
				list.removeAt(currentIndex-1);
				numberOfPeople--;
		}

		cout << "Person number: " << list.popBack() << "is left" << endl;
	}
	return 0;
}
开发者ID:Pufferfiz,项目名称:Portfolio,代码行数:30,代码来源:Driver.cpp

示例2: main

int main() 
{
    // Grab current cout flags, used for when the stream is altered and the user wants
    //   to reset it to the default values: 
    ios::fmtflags f( cout.flags() );

    // Test 1:
    {
      SinglyLinkedList<char>* list = new SinglyLinkedList<char>();

      char var = 'A';

      for (int i = 1; i <= 10; i++) 
        {
        list->pushBack(var);
        var++;
      }

      cout << endl << "Test 1 - Char list:" << endl << "\t";
      list->print();
        cout << endl;
    }

    // Reset cout stream flags:
    cout.flags(f);

    // Test 2:
    {
        DoublyLinkedList<myType>* list = new DoublyLinkedList<myType>();

        myType var = 1;

        for (int i = 1; i <= 10; i++) 
        {
            list->pushBack(var);
            var++;
        }

        cout << endl << "Test 2 - Int list:" << endl << "\t";
        list->print();
        cout << endl;
    }

    // Reset cout stream flags:
    cout.flags(f);

    // Test 3:
    {
        BinaryTree<int>* bt = new BinaryTree<int>();

        // Insert a bunch of stuff:
        bt->insert(11);
        bt->insert(6);
        bt->insert(8);
        bt->insert(19);
        bt->insert(4);
        bt->insert(10);
        bt->insert(5);
        bt->insert(17);
        bt->insert(43);
        bt->insert(49);
        bt->insert(31);

        // Print tree preOrderTraversal:
        cout << endl << "Binary Tree PreOrderTravesal:" << endl << "\t";
        bt->preOrderTraversal();
        cout << endl;

        // Print tree inOrderTraversal:
        cout << endl << "Binary Tree InOrderTravesal:" << endl << "\t";
        bt->inOrderTraversal();
        cout << endl;

        // Print tree postOrderTraversal:
        cout << endl << "Binary Tree PostOrderTravesal:" << endl << "\t";
        bt->postOrderTraversal();
        cout << endl;
    }

    cout << endl;

    return 0;
}
开发者ID:calebwherry,项目名称:Cpp-Libraries,代码行数:83,代码来源:data-structure-tests.cpp


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