本文整理汇总了C++中DLList::append方法的典型用法代码示例。如果您正苦于以下问题:C++ DLList::append方法的具体用法?C++ DLList::append怎么用?C++ DLList::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DLList
的用法示例。
在下文中一共展示了DLList::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
DLList<scalar> myList;
for (int i = 0; i<10; i++)
{
myList.append(1.3*i);
}
myList.append(100.3);
myList.append(500.3);
Info<< nl << "And again using STL iterator: " << nl << endl;
forAllIter(DLList<scalar>, myList, iter)
{
Info<< "element:" << *iter << endl;
}
Info<< nl << "And again using the same STL iterator: " << nl << endl;
forAllIter(DLList<scalar>, myList, iter)
{
Info<< "Removing " << myList.remove(iter) << endl;
}
示例2: main
int main()
{
using namespace std;
DLList<int> myIntDLL;
cout << "Prepending: 5" << endl;
myIntDLL.prepend(5);
myIntDLL.printList();
cout << "Prepending: 4" << endl;
myIntDLL.prepend(4);
myIntDLL.printList();
cout << "Prepending: 3" << endl;
myIntDLL.prepend(3);
myIntDLL.printList();
cout << "Appending: 9" << endl;
myIntDLL.append(9);
myIntDLL.printList();
cout << "Appending: 8" << endl;
myIntDLL.append(8);
myIntDLL.printList();
cout << "Appeding: 7" << endl;
myIntDLL.append(7);
myIntDLL.printList();
cout << "Current data: " << *myIntDLL.getValue() << endl;
cout << "Moving to end" << endl;
myIntDLL.moveToEnd();
cout << "Current data: " << *myIntDLL.getValue() << endl;
cout << "Moving to start" << endl;
myIntDLL.moveToStart();
cout << "Current data: " << *myIntDLL.getValue() << endl;
cout << "Iterating through list with next function" << endl;
for (int i = 0; i < 10; i++)
{
cout << "Current data: " << *myIntDLL.getValue() << endl;
cout << "Next: " << myIntDLL.next() << endl;
}
cout << "Iterating through list with prev function" << endl;
for (int i = 0; i < 10; i++)
{
cout << "Current data: " << *myIntDLL.getValue() << endl;
cout << "Prev: " << myIntDLL.prev() << endl;
}
cout << "Number of links active: " << myIntDLL.numActive() << endl;
cout << "Number of links free: " << myIntDLL.numFree() << endl;
cout << "Clearing list" << endl;
myIntDLL.clear();
myIntDLL.printList();
cout << "Number of links active: " << myIntDLL.numActive() << endl;
cout << "Number of links free: " << myIntDLL.numFree() << endl;
return 0;
}