本文整理汇总了C++中ListElement::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ ListElement::getValue方法的具体用法?C++ ListElement::getValue怎么用?C++ ListElement::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListElement
的用法示例。
在下文中一共展示了ListElement::getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
LinkedList<T>& LinkedList<T>::operator=(const LinkedList<T> &ListToBeAssigned)
{
std::cout << "Copy assignement operator called for @ " << this << std::endl;
if (&ListToBeAssigned != this) {
// Free The memory held by this
deleteList();
ListElement<T> *copy = ListToBeAssigned._head;
if (copy != nullptr) {
_head = new ListElement<T>(copy->getValue());
ListElement<T> *curr = _head;
copy = copy->getNext();
// copy List Elements Until we reach the end of the
// List to be copied
while (copy != nullptr) {
curr->setNext(new ListElement<T>(copy->getValue()));
copy = copy->getNext();
curr = curr->getNext();
}
}
}
return *this;
}
示例2: revertNew
void List::revertNew()
{
ListElement *previous = new ListElement(mHead->getValue());
// Sets new Tail
mTail = previous;
ListElement *step = mHead->getNext();
while (step) {
ListElement *clone = new ListElement(step->getValue());
clone->setNext(previous);
previous = clone;
step = step->getNext();
}
// Head of reverted List now in previous
while (mHead) {
step = mHead;
mHead = mHead->getNext();
delete step;
}
mHead = previous;
}