say that you have a deck of cards in your hand
you draw them one by one, show to your audience and put them on a table
now you are wondering why you don't have any cards in your hand.
> Shouldn't it just reset after I call it again?
no, ¿why would it? when you modify a variable, its value changes.
> Why does it suddenly change up my entries when I never explicitly wanted it to?
¿what do you think you are doing here
table[i] = table[i]->next;
?
you are changing table[i]
> but this is my first time making a hash table.
¿do you realise that you have an array of linked lists?
table[i] is a linked list, and you would make everything clearer if you treat it as such
1 2 3 4
|
void insert(string key, string value){
index = hash_function(key);
table[index].push_back( entry(key, value ) );
}
|
Now look at your display() function and notice that you are moving the head of the list