本文整理汇总了C++中DoublyLinkedList::getAfterLast方法的典型用法代码示例。如果您正苦于以下问题:C++ DoublyLinkedList::getAfterLast方法的具体用法?C++ DoublyLinkedList::getAfterLast怎么用?C++ DoublyLinkedList::getAfterLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoublyLinkedList
的用法示例。
在下文中一共展示了DoublyLinkedList::getAfterLast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
// copy constructor
DoublyLinkedList::DoublyLinkedList(const DoublyLinkedList& dll)
{
// Initialize the list
header.next = &trailer; trailer.prev = &header;
DListNode *p, *node = header.next;
// remove old list
if (header.next != &trailer)
{
while (node->next != 0)
{
p = node;
node = node->next;
delete p;
}
}
cout<<"List Deleted"<<endl;
// create a new list
node = dll.getFirst();
while (node != dll.getAfterLast())
{
this->insertLast(node->getElem());
node = node->next;
}
}
示例2: DoublyLinkedListLength
// return the list length
int DoublyLinkedListLength(DoublyLinkedList& dll) { //O(n)
DListNode *current = dll.getFirst();
int count = 0;
while(current != dll.getAfterLast()) {
count++;
current = current->getNext(); //iterate
}
return count;
}
示例3: while
// copy constructor
DoublyLinkedList::DoublyLinkedList(const DoublyLinkedList& dll) //O(n)
{
// Initialize the list
header.next = &trailer; trailer.prev = &header;
DListNode *current = dll.getFirst();
while(current != dll.getAfterLast())
{
insertFirst(current->getElem());
current=current->getNext();
}
}
示例4: while
// copy constructor
DoublyLinkedList::DoublyLinkedList(DoublyLinkedList& dll)
{
// Initialize the list
header.next = &trailer; trailer.prev = &header;
if (!dll.isEmpty()){
DListNode* node;
node=dll.getFirst();
while (node!=dll.getAfterLast()){
insertLast(node->getElem());//insert new element
node=node->getNext();//set node to next node
}
}
}