Page 1 of 1

Declaring STL iterators for ADTs inside ADTs?

PostPosted: Sun May 13, 2007 10:12 pm
by Slater
Alright, for my final project this year, I have to create a hashtable. Now, the professor said we have to use her model for a hashtable and not any STL heaps.

So, that means that I have to use this... THING... to store all the info for the hash table...

Code: Select all
vector<list<pair<Key, Val> > > hashTable;

The hash table will be a custom template class where Key is to be defined as a string and Val is to be defined as a floating-point number

That's right, a string and float being held by a Pair being held by lists being held by vectors... Sue me if I'm just confused about something here, but it seems to be the most bogus overcomplicated thing ever.

Anyhow, I guess I can put up with it, but somewhere along the line I need to do something like this in order to traverse the hashTable...

Code: Select all
for (vector<list<pair<Key, Val> > >::iterator Ite = hashTable.begin(); Ite != hashTable.end(); Ite++)


Which by all means LOOKS correct, but... No, it doesn't work, never compiles. I get the standard "expected `;' before 'Ite' " compiler message, which naturally Google can't help me with because every n00b to C++ has posted that on a million message boards before wondering why "int a (endline)" wouldn't compile.

Does anyone know how I can propperly declare this iterator?