本文整理汇总了C++中node::getPrev方法的典型用法代码示例。如果您正苦于以下问题:C++ node::getPrev方法的具体用法?C++ node::getPrev怎么用?C++ node::getPrev使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node
的用法示例。
在下文中一共展示了node::getPrev方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteFromList
bool DoublyLinkList::deleteFromList(int val)
{
node *curr;
if (!head || !tail)
{
return false;
}
if (head->getNext() == NULL || tail->getPrev() == NULL)
{
curr = head;
head = tail = NULL;
delete curr;
return true;
}
if (head->getValue() == val)
{
curr = head->getNext();
curr->setPrev(NULL);
delete head;
head = curr;
return true;
}
if (tail->getValue() == val)
{
curr = tail->getPrev();
curr->setNext(NULL);
delete tail;
tail = curr;
return true;
}
curr = head;
while (curr)
{
if (curr->getValue() == val)
{
curr->getNext()->setPrev(curr->getPrev());
curr->getPrev()->setNext(curr->getNext());
delete curr;
return true;
}
curr = curr->getNext();
}
return false;
}