To implement an open hash table in C ++, I thought I would define a vector containing pointers to vectors containing data. For simplicity, let me say that I want a hash table that can store ints. I suggested that I need this vector< vector<int>* >.
The resulting data structure might look something like this:
[index 0] 8, 6, 2
[index 1] (empty)
[index 2] 9, 12, 15, 28, 1
I could create a static array of pointers vector<int>, but I wanted to be able to add more indexes as I go.
To record the elements, I wanted to do something like this:
for (unsigned int i = 0; i < myHashtable.size(); i++) {
cout << "[index " << i << "]";
for (unsigned int j = 0; j < myHashtable[i]->size(); j++) {
cout << " " << *(myHashtable[i])[j];
}
cout << "\n";
}
This code does not compile. What is the right way to turn to *(myHashtable[i])[j]?