| Author |
Linked List Remove?
|
Luke Gotto
Greenhorn
Joined: Apr 04, 2008
Posts: 2
|
|
When i run this it removes all of the elemets of the list except the last one... Any ideas why it is not geting to the last node? public E remove() // delete link with given key { E tmp; tmp = null; cursor = first; previous = first; if (cursor == null) return null; else tmp = first.item; previous = cursor; first = cursor.next; length = length -1; return tmp; }
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Sorry, I really can't figure out how this is intended to work. I think it might help if you explained the steps in English. It's a good way to check your own logic, and it would give us a clear idea of what you're expecting to happen. (Code Tags with clean indentation would also help.)
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
 |
|
|
subject: Linked List Remove?
|
|
|