Advertisement
Guest User

Linked List Delete (No special case)

a guest
Mar 20th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. bool ContactList::remove(const std::string& key)
  2. {
  3.     NodePtr *pp = &head;
  4.     while (*pp)
  5.     {
  6.         if ((*pp)->data.key == key)
  7.         {
  8.             NodePtr *tmp = *pp;
  9.             *pp = tmp->link;
  10.             delete tmp;
  11.             return true;
  12.         }
  13.         pp = &(*pp)->link;
  14.     }
  15.     return false;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement