TotalInsanity
Programmer
Hello All.
I could do with some expert help here, so here goes to all you gurus!
I have created a 'map within a map' to form a graph structure in c++.
I have declared it like this:
I have created an instance as follows:
My graph structure holds placename and location data and I have added it to the structure like this:
When I look at the map in the debugger it shows me that:
[0] Nottingham - First = Nottingham, Second = [0] Coventry, 52.65
With First and Second being map iterators.
My question here really is that in a normal multimap I can access the data using
and it would display the data held in the map.
Using the structure I have shown above, I am unsure how I access the second maps data and edges.
If I use a find() on my structure it will find say ("Nottingham") and will have an iterator pointing to this data entry, but then how do I access the second keys values?? (i.e. Coventry and the double data (52.65).
I have tried loads of things now and I am tearing my hair out!
Can one of you experts help me out here so I can access the structures data please??
If you want more info just ask here and I'll provide it!
Thanks in advance Gurus! Blue Peter badges for anyone that helps :OP
I could do with some expert help here, so here goes to all you gurus!
I have created a 'map within a map' to form a graph structure in c++.
I have declared it like this:
Code:
typedef map<string, double> stringVector; //map of doubles indexed by strings
typedef map<string, stringVector> graph; //a two-dimensional sparse array, indexed by strings and holding double values
I have created an instance as follows:
Code:
graph distanceMap; // declare the graph that holds the map
My graph structure holds placename and location data and I have added it to the structure like this:
Code:
distanceMap["Nottingham"]["Coventry"] = 52.65;
When I look at the map in the debugger it shows me that:
[0] Nottingham - First = Nottingham, Second = [0] Coventry, 52.65
With First and Second being map iterators.
My question here really is that in a normal multimap I can access the data using
Code:
iteratorname->first and iteratorname->second
Using the structure I have shown above, I am unsure how I access the second maps data and edges.
If I use a find() on my structure it will find say ("Nottingham") and will have an iterator pointing to this data entry, but then how do I access the second keys values?? (i.e. Coventry and the double data (52.65).
I have tried loads of things now and I am tearing my hair out!
Can one of you experts help me out here so I can access the structures data please??
If you want more info just ask here and I'll provide it!
Thanks in advance Gurus! Blue Peter badges for anyone that helps :OP