Closed derekdogg closed 11 months ago
Code below, commented out makes more sense? This will go back to 1st slot. (i.e. loop around array). Code as it stands will not go back to 1st slot
Apologies if this off the mark, not a c coder, just reading the code.
/ Hash Tables find-entry < Optimization next-index index = (index + 1) % capacity; /
I believe it's an optimization. Because the capacity is always a power of 2, the current code
index = (index + 1) & (table->capacity - 1);
is equivalent to the commented out
index = (index + 1) % capacity;
Code below, commented out makes more sense? This will go back to 1st slot. (i.e. loop around array). Code as it stands will not go back to 1st slot
Apologies if this off the mark, not a c coder, just reading the code.
/ Hash Tables find-entry < Optimization next-index index = (index + 1) % capacity; /