本文整理汇总了C++中SimpleList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleList::empty方法的具体用法?C++ SimpleList::empty怎么用?C++ SimpleList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleList
的用法示例。
在下文中一共展示了SimpleList::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main(void)
{
int i,count;
MyNode *n1,*middle,*beforeMiddle,*last;
cout << "Memory at start: " << coreleft() << " bytes\n";
// Create a linked list of 10 nodes adding at the head of the list.
for (i = 0; i < 10; i++) {
n1 = new MyNode(i);
l.addToHead(n1);
if (i == 0)
last = n1;
if (i == 5)
beforeMiddle = n1;
if (i == 4)
middle = n1;
}
cout << "Memory after creating list: " << coreleft() << " bytes\n";
dumpList(l);
// Add a new node after the head of the list and after a middle node
n1 = new MyNode(20);
l.addAfter(n1,l.peekHead());
n1 = new MyNode(21);
l.addAfter(n1,last);
n1 = new MyNode(22);
l.addAfter(n1,middle);
dumpList(l);
// Remove the middle object from the list using beforeMiddle as the
// previous node in the list.
delete l.removeNext(beforeMiddle);
dumpList(l);
// Remove all remaining nodes with removeFromHead().
count = l.numberOfItems();
for (i = 0; i < count+5; i++)
delete l.removeFromHead();
dumpList(l);
cout << "Memory: " << coreleft() << " bytes\n";
for (i = 0; i < 10; i++) {
n1 = new MyNode(i);
l.addToHead(n1);
}
// Display the list using iterators to move through the list.
SimpleListIterator<MyNode> it1;
for (it1 = l; it1; it1++)
cout << it1.node()->id() << " ";
cout << endl;
for (it1.restart(); it1;)
cout << it1++->id() << " ";
cout << endl;
l.empty();
cout << "Memory at end: " << coreleft() << " bytes\n\n";
}