|
@@ -77,12 +77,14 @@ class List
|
|
|
lenght++;
|
|
|
}
|
|
|
|
|
|
- virtual void pop()
|
|
|
+ virtual Node<T> pop()
|
|
|
{
|
|
|
// Сделать проверку на пустой список
|
|
|
+ Node<T> result = end;
|
|
|
end = end->prev;
|
|
|
end->next = nullptr;
|
|
|
lenght--;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
virtual void pop(Node<T>* node)
|
|
@@ -90,21 +92,23 @@ class List
|
|
|
node->next->prev = node->prev;
|
|
|
node->prev->next = node->next;
|
|
|
lenght--;
|
|
|
+ return node;
|
|
|
}
|
|
|
|
|
|
virtual void pop(int index)
|
|
|
{
|
|
|
+ Node<T> result;
|
|
|
if (index==0) {
|
|
|
+ result = start;
|
|
|
start = getNode(index+1);
|
|
|
lenght--;
|
|
|
- return;
|
|
|
}
|
|
|
if (index>=lenght-1) {
|
|
|
- pop();
|
|
|
- return;
|
|
|
+ result = pop();
|
|
|
}
|
|
|
Node<T>* node = getNode(index);
|
|
|
- pop(node);
|
|
|
+ result = pop(node);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
T operator[](int index)
|