Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Feb 10th, 2010  |  syntax: C++  |  size: 0.97 KB  |  hits: 74  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. template<class T>
  2. Node<T>* SAList<T>::search(const T& key, bool (*match)(const T&,const T&))
  3. {
  4.     Node<T> *curr, *temp;
  5.     bool stop = false;
  6.  
  7.     curr = head;
  8.  
  9.     while(curr != NULL && stop != true){
  10.       if((*match)(curr->data_,key) == true){
  11.           temp = curr;
  12.           if(temp->prev_ != NULL) {
  13.              if(temp != NULL){
  14.                 temp = temp->next_;
  15.                 temp->prev_ = curr->prev_;
  16.                 temp = temp->prev_;
  17.                 temp->next_ = curr->next_;
  18.  
  19.            /*     curr->prev_ = NULL;   // Commented this out for
  20.                 head->prev_ = curr;     // The moment until I figure
  21.                 curr->next_ = head; */  // Out the problem
  22.                 head = curr;  
  23.              }
  24.              else{
  25.                 temp = temp->prev_;
  26.                 temp->next_ = NULL;
  27.              }
  28.           }
  29.          stop = true;
  30.       }
  31.       if(stop == false)
  32.         curr = curr->next_;
  33.     }
  34.     return curr;
  35. }