本文整理汇总了C++中DLNode::setNextNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DLNode::setNextNode方法的具体用法?C++ DLNode::setNextNode怎么用?C++ DLNode::setNextNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DLNode
的用法示例。
在下文中一共展示了DLNode::setNextNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeFirst
bool DLList::removeFirst(int target){
if(get(target) == true){
DLNode* b = head;
DLNode* previous = b;
while(b->getContents() != target){
previous = b;
b = b->getNextNode();
}
if(b->getNextNode() != NULL){
previous->setNextNode(b->getNextNode());
delete b;
}
else{
delete b;
previous->setNextNode(NULL);
}
size--;
}
}
示例2: get
bool DLList::get(int target) const{
DLNode* node = head;
bool isPresent = false;
while(node->getNextNode() != NULL){
if(node->getContents() == target){
isPresent = true;
}
node->setNextNode(node->getNextNode());
}
return isPresent;
}
示例3: pushFront
void DLList::pushFront(int newContents){
DLNode* node = new DLNode(newContents);
if (head == NULL){
tail = node;
}
else{
node->setNextNode(head);
}
head = node;
size++;
}
示例4: pushBack
void DLList::pushBack(int newContents){
if(head == NULL){
pushFront(newContents);
}
else{
DLNode* node = new DLNode(newContents);
DLNode* b = head;
while(b->getNextNode() != NULL){
b = b->getNextNode();
}
b->setNextNode(node);
size++;
}
}
示例5: popBack
void DLList::popBack(){
if(head != NULL)
{
if(head->getNextNode() == NULL){
popFront();
}
else{
DLNode* b = head;
DLNode* previous = b;
while(b->getNextNode() != NULL){
previous = b;
b = b->getNextNode();
}
delete b;
previous->setNextNode(NULL);
size--;
}
}
}