Skip to content

Commit 661955e

Browse files
committed
Merge pull request #7 from thirtythreeforty/master
Fix add into position 0
2 parents aef49d2 + baef67c commit 661955e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

LinkedList.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ int LinkedList<T>::size(){
166166
template<typename T>
167167
bool LinkedList<T>::add(int index, T _t){
168168

169-
// if(index == 0)
170-
// return shift(_t);
171-
172169
if(index >= _size)
173170
return add(_t);
174171

172+
if(index == 0)
173+
return unshift(_t);
174+
175175
ListNode<T> *tmp = new ListNode<T>(),
176176
*_prev = getNode(index-1);
177177
tmp->data = _t;

0 commit comments

Comments
 (0)