Linked List deleting Help
Hey all i am trying to delete a set number of items in a linked list. Here is the code for delete my item.
Right now it only deletes the 1 string i pass to it "deleteItem". However, i wish to delete the next 8 blocks after the "deleteItem".
void unorderedLinkedList<Type>::deleteNode(const Type& deleteItem)
nodeType<Type> *current; //pointer to traverse the list
nodeType<Type> *trailCurrent; //pointer just before current
found = false;
trailCurrent = first; //set trailCurrent to point
//to the first node
current = first->link; //set current to point to
//the second node
while (current != NULL && !found)
if (current->info != deleteItem)
trailCurrent = current;
current = current-> link;
found = true;
if (found) //Case 3; if found, delete the node
trailCurrent->link = current->link;
if (last == current) //node to be deleted
//was the last node
last = trailCurrent; //update the value
delete current; //delete the node from the list
cout << "The item to be deleted is not in "
<< "the list." << endl;
Say i have this in the list right now.
Now the user would pick "bob" and with the code above, would delete "bob" but leave everything else. I wish to take out "bob, barker, is, pretty, old, but, still, seems, to" when the code above executes.
bob barker is pretty old but still seems to get all the ladies
I'm unsure on how to go about doing that. Any help would be great! :)