Browse Source

Fixed a bug in SLList<T>::remove().

release/0.19
JustinAJ 10 years ago
parent
commit
6400a1542e
  1. 6
      Jupiter/SLList.h

6
Jupiter/SLList.h

@ -169,11 +169,13 @@ template<typename T> T *Jupiter::SLList<T>::get(size_t index) const
template<typename T> T *Jupiter::SLList<T>::remove(size_t index) template<typename T> T *Jupiter::SLList<T>::remove(size_t index)
{ {
Jupiter::SLList<T>::Node *t = head; Jupiter::SLList<T>::Node *t = head;
for (size_t i = 0; i != index; i++) t = t->next; for (size_t i = 0; i != index; i++)
t = t->next;
Jupiter::SLList<T>::Node *t2 = t->next; Jupiter::SLList<T>::Node *t2 = t->next;
t->next = t2->next;
T *r = t2->data; T *r = t2->data;
delete t2; delete t2;
Jupiter::List<T>::length--; --Jupiter::List<T>::length;
return r; return r;
} }

Loading…
Cancel
Save