Re: nested stl map question
Ah! okay, I have something working.
THETA_RESULTS::iterator thetaX = results.begin()->second.begin();
for( ; thetaX != results.begin()->second.end(); ++thetaX )
RESULTS::iterator phiX = results.begin();
for( ; phiX != results.end(); ++phiX )
os << phiX->second[ thetaX->first ] << ",";
os << std::endl << ",,";
If there is a better method of getting done what I want, I'd like to
On Mar 23, 12:56 pm, "PaulH" <paul.h...@gmail.com> wrote:
I have an stl map container declared as:
typedef std::map< int, float > THETA_RESULTS;
typedef std::map< int, THETA_RESULTS > RESULTS;
I populate it kind of like this (where phi and theta are angles
measured in degrees):
for( int phi = 0; phi <= 180; phi += 30 )
for( int theta = 0; theta <= 360; theta += 30 )
m_ThetaResults[ phi ][ theta ] = some_value;
I would like to print the results like this, but I'm not quite sure
<angles> Phi0, Phi1, Phi2, Phi3, Phi4, Phi5, ...
Theta0, val00, val10, val20, val30, val40, val50,...
Theta1, val01, val11, val21, val31, val41, val51,...
Theta2, val02, val12, val22, val32, val42, val52,...
I'm trying to do something like this, but this, obviously, doesn't
RESULTS::const_iterator phi = obj.m_results->begin();
THETA_RESULTS::const_iterator theta = (*phi).second.begin();
for( ; theta != (*phi).second.end(); ++theta )
cout << (*theta).first << ",";
for( ; phi != obj.m_results->end(); ++phi )
cout << ( *theta ).second << ",";
cout << std::endl;
phi = obj.m_results->begin();
I would appreciate any help. Thanks,