Declaring STL iterators for ADTs inside ADTs?

The geek forum. PHP, Perl, HTML, hardware questions etc.. it's all in here. Got a techie question? We'll sort you out. Ask your questions or post a link to your own site here!

Declaring STL iterators for ADTs inside ADTs?

Postby Slater » Sun May 13, 2007 10:12 pm

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?
Image
User avatar
Slater
 
Posts: 2671
Joined: Sat May 22, 2004 10:00 am
Location: Pacifica, Caliphornia

Return to Computing and Links

Who is online

Users browsing this forum: No registered users and 207 guests