Derek
By: a guest | Feb 9th, 2010 | Syntax:
C++ | Size: 0.89 KB | Hits: 19 | Expires: Never
template<class T>
Node<T>* SAList<T>::search(const T& key, bool (*match)(const T&,const T&))
{
Node<T> *curr, *temp;
bool stop = false;
curr = head;
while(curr != NULL && stop != true){
if((*match)(curr->data_,key) == true){
temp = curr;
if(temp->prev_ != NULL) {
if(temp != NULL){
temp = temp->next_;
temp->prev_ = curr->prev_;
temp = temp->prev_;
temp->next_ = temp->next_;
/* curr->prev_ = NULL;
head->prev_ = curr;
curr->next_ = head;
head = curr; */
}
else{
temp = temp->prev_;
temp->next_ = NULL;
}
}
stop = true;
}
if(stop == false)
curr = curr->next_;
}
return curr;
}