I have a function find(x) in my linked list, that search through the listfor the value and return an Iterator pointing to the first node contaning value x. if x is not found in the list, it returns an Iterator pointing to NULL.
it should be a linear search.
would you please help me fix this code.
this is what I wrote, but it dosent work.
thanks
//find function
template<typename T>
Iterator<T> LinkedList<T>::find(T value)
{
Node<T>* pos = NULL;
Iterator<T> res=pos.position;
Node<T>* current = first;
Iterator<T> iter=current.position;
while (current != NULL) {
if(current->data===value)
return iter;
else
current=current->next;
}
return res;
}