For class I need to make a dynamically expanding hash table that expands when the number of bindings reaches certain values – 509,1021, 2039, 4093, etc. I understand just about everything else but I’m not sure how to check which value the table should expand to next.
I think that we’re supposed to use enumerations, but I don’t understand how to get the “next” enumeration value. I.e., if my hash table currently has 1022 bindings I should expand the underlying array to size 2039, but how do I know how to do that? Or am I approaching this the wrong way?
Sorry in advance if this is a stupid question, but it’s not addressed in my book and I’m still very new when it comes to C.
You can’t use enumerations for this purpose in C.
You probably want to put the thresholds in a constant array, and maintain an index to point at the current threshold: