Hey guys I am trying to wrap my head around implementing this. I have an abstract based class and three derived classes. I also have a templated hash table class(using chaining as my collision resolution method, an array of stl lists), and a class to parse commands from a file, this also holds the instantiation of the hash table. My question is that since my command parsing class's constructor instantiates the hash table in the main driver(unable to modify) how can I make this dynamically allocated using data from the file? thanks guys let me know if I didnt explain clearly or if you need more code.
Many implementations simply allocate some initial size (for example 16) and then if while adding more and more data the number of elements exceeds some threshold (for example 0.75 * curSize), the table is reallocated (i.e. new internal table twice as large is created, data are copied into it, old table is forgotten).
If you've determined too many collisions are happening (via the heuristic of your choice) then make a new vector, insert the elements into that vector, and swap the new vector with the old vector (or use move assignment.)