M
Markus Kern
Hi!
I have defined a structure:
struct Coor3d
{
float x,y,z;
};
This is supposed to be stored in a 2d-vector:
------------
typedef vector< vector<Coor3d> > DCDStep;
DCDStep vDCDStep;
-------------
since I will have multiple sets of those coordinates.
However, here my trouble starts. In order to
access 16nth sets x(22), I have done this (which surely
is a newbies way to do so, suggestions welcome)
------------
typedef vector<Coor3d>::iterator Ic3d;
Ic3d ic3d(vDCDStep[16].begin());
cout << (ic3d+22)->x;
------------
Nevertheless, it works, but here comes
where I'm lost: I need to introduce another
vector, in which vDCDStep is stored, so I
did this:
-----------
typedef vector<DCDStep> DCDFile;
DCDFile vDCDFile;
DCDFile::iterator iDCDFile;
-----------
vDCDFile.push_back(vDCDStep) works, but how
can I access x,y,z, now?
This whole thing looks cruel, anyway. STL was
supposed to make life easier, however, *this*
has not become particulary easy compared to
C's array-solutions.
Anyone any idea where my thinking has gone wrong?
Thank to all for anwers
M.K.
I have defined a structure:
struct Coor3d
{
float x,y,z;
};
This is supposed to be stored in a 2d-vector:
------------
typedef vector< vector<Coor3d> > DCDStep;
DCDStep vDCDStep;
-------------
since I will have multiple sets of those coordinates.
However, here my trouble starts. In order to
access 16nth sets x(22), I have done this (which surely
is a newbies way to do so, suggestions welcome)
------------
typedef vector<Coor3d>::iterator Ic3d;
Ic3d ic3d(vDCDStep[16].begin());
cout << (ic3d+22)->x;
------------
Nevertheless, it works, but here comes
where I'm lost: I need to introduce another
vector, in which vDCDStep is stored, so I
did this:
-----------
typedef vector<DCDStep> DCDFile;
DCDFile vDCDFile;
DCDFile::iterator iDCDFile;
-----------
vDCDFile.push_back(vDCDStep) works, but how
can I access x,y,z, now?
This whole thing looks cruel, anyway. STL was
supposed to make life easier, however, *this*
has not become particulary easy compared to
C's array-solutions.
Anyone any idea where my thinking has gone wrong?
Thank to all for anwers
M.K.