fixing the copy all issue in erase

This commit is contained in:
Jidong Xiao
2023-10-10 13:50:58 -04:00
parent 043e1c5745
commit e9b69640af

View File

@@ -144,15 +144,11 @@ class dslist {
/* iterator implementation */ /* iterator implementation */
void erase(iterator itr){ void erase(iterator itr){
dslist<T>::iterator itr2 = itr; dslist<T>::iterator itr2(itr.ptr->next);
itr2++; itr.ptr->prev->next = itr2.ptr;
// Question: is this right? itr2.ptr->prev = itr.ptr->prev;
while (itr2 != this->end()) { delete itr.ptr;
*itr = *itr2; size_ = size_ - 1;
itr++;
itr2++;
}
this->pop_back();
} }
void insert(iterator itr, const T& value){ void insert(iterator itr, const T& value){