View difference between Paste ID: m192ab48a and
SHOW: | | - or go back to the newest paste.
1-
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
}