From 6400a1542e1d005e47cd5c9989a58a1731e00e27 Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Sun, 7 Jun 2015 09:36:36 -0400 Subject: [PATCH] Fixed a bug in SLList::remove(). --- Jupiter/SLList.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jupiter/SLList.h b/Jupiter/SLList.h index cfbaa7d..e9beb46 100644 --- a/Jupiter/SLList.h +++ b/Jupiter/SLList.h @@ -169,11 +169,13 @@ template T *Jupiter::SLList::get(size_t index) const template T *Jupiter::SLList::remove(size_t index) { Jupiter::SLList::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::Node *t2 = t->next; + t->next = t2->next; T *r = t2->data; delete t2; - Jupiter::List::length--; + --Jupiter::List::length; return r; }