Search and erase implementation

I am having a problem with erase function. Please help.

void erase(string key){
		int idx=hashfun(key);
		Node<T>*temp=table[idx];
		Node<T>*prev=NULL;
		while(temp){
			if(temp->key==key){
				if(prev)prev->next=temp->next;
				else table[idx]=temp->next;
				temp->next=NULL;
				delete temp;
			}
			prev=temp;
			temp=temp->next;
		}
	}

steps

  1. find the hasvalue corresponding to given key
  2. find the node which we have to delete and then delete that node
    to delete node you also need prev pointer (linked list Deletion concept)

it is quiet simple
i hope you understood this
if not feel free to ask