Share Pastebin
Guest
Public paste!

Derek

By: a guest | Feb 9th, 2010 | Syntax: C++ | Size: 0.89 KB | Hits: 19 | Expires: Never
Copy text to clipboard
  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_ = temp->next_;
  18.            /*     curr->prev_ = NULL;
  19.                 head->prev_ = curr;
  20.                 curr->next_ = head;
  21.                 head = curr;  */
  22.              }
  23.              else{
  24.                 temp = temp->prev_;
  25.                 temp->next_ = NULL;
  26.              }
  27.           }
  28.          stop = true;
  29.       }
  30.       if(stop == false)
  31.         curr = curr->next_;
  32.     }
  33.     return curr;
  34. }