Erase function in hashmap

void erase(string key){
   int idx=hashFn(key);
   node<T>*temp=table[idx];
   if(temp->key==key){
   	  table[idx]=temp->next;
   	  temp->next=NULL;
   	  delete temp;
   	  current_size--;
   	  return;
   }
   while(temp!=NULL){
   	 if(temp->next->key==key){
   	 	node<T>*ptr=temp->next;
   	 	temp->next=ptr->next;
   	 	ptr->next=NULL;
   	 	delete ptr;
   	 	return;
   	 }
   	 temp=temp->next;
   }
}

in the first if statement why are we doing current_size-- .we have already assigned table[idx]=temp->next so why are we saying we need to decrease current_size by -1

I want to know why we are doing current_size-- in the first if statement because havent we already assigned the value of temp->next to table[idx] so why are we decreasing size of table?

@aryamaan1011 Hey ,you are correct but current size tell the size of map suppose we want to acess the size of map directly in function so we can use directly use current size variable,that table[indx]=temp->next is true but it will not tell the current size of map that will just erase the member.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.