M
Milica Milojevic
Hi,
I have created a list called measuresQueue (list<pssMeasure *> measuresQueue; ) which is consisted of ten elements. Then I used measuresQueue.size() function. When I did the printf of the previous function it prints me the number four not ten. Can someone help me with this problem.
Here is my code:
In for loop I have entered my elements of the list:
for (filtertime_t=0; filtertime_t<=1.8; filtertime_t=filtertime_t+0.2) {
pssMeasure *mes = measureReceived(filtertime_t,y,mes_vect,mes_cov);
y++;
process_th->critical_section->writeMeasures(mes);
}
Here it is the measureReceived function description:
pssMeasure * measureReceived(double timeStamp,int j,double array[3][10], double array_cov[3]) {
pssMeasure *mes = new pssMeasure();
mes->track_id =7;
mes->timeStamp =timeStamp;
for (int i=0; i<3; i++)
{
mes->z_t=array[j];
}
for(int i = 0; i < 3; i++) {
for(int k = 0; k < 3; k++)
mes->cov_z[k] = 0.0;
mes->cov_z = array_cov;
}
return mes;
}
After creating mes I store them using the function writeMeasures:
void CPSSCriticalSection::writeMeasures(pssMeasure* pss_mes) {
measuresQueue.push_back(pss_mes);}
In order to check that my all elements are stored in the measuresQueue listI have used this after the measuresQueue.push_back(pss_mes);
cout << "hello1" << endl
printf("%f %f %f %f \n", pss_mes->timeStamp, pss_mes->z_t[0], pss_mes->z_t[1], pss_mes->z_t[2]);
Everything was fine until I wanted to see the size of my list measuresQueuewith the: cout << "measuresQueue. size: " << measuresQueue.size() << '\n';
I always get the number 4 instead of ten. I don't know what is the reason?
Thank you,
M.
I have created a list called measuresQueue (list<pssMeasure *> measuresQueue; ) which is consisted of ten elements. Then I used measuresQueue.size() function. When I did the printf of the previous function it prints me the number four not ten. Can someone help me with this problem.
Here is my code:
In for loop I have entered my elements of the list:
for (filtertime_t=0; filtertime_t<=1.8; filtertime_t=filtertime_t+0.2) {
pssMeasure *mes = measureReceived(filtertime_t,y,mes_vect,mes_cov);
y++;
process_th->critical_section->writeMeasures(mes);
}
Here it is the measureReceived function description:
pssMeasure * measureReceived(double timeStamp,int j,double array[3][10], double array_cov[3]) {
pssMeasure *mes = new pssMeasure();
mes->track_id =7;
mes->timeStamp =timeStamp;
for (int i=0; i<3; i++)
{
mes->z_t=array[j];
}
for(int i = 0; i < 3; i++) {
for(int k = 0; k < 3; k++)
mes->cov_z[k] = 0.0;
mes->cov_z = array_cov;
}
return mes;
}
After creating mes I store them using the function writeMeasures:
void CPSSCriticalSection::writeMeasures(pssMeasure* pss_mes) {
measuresQueue.push_back(pss_mes);}
In order to check that my all elements are stored in the measuresQueue listI have used this after the measuresQueue.push_back(pss_mes);
cout << "hello1" << endl
printf("%f %f %f %f \n", pss_mes->timeStamp, pss_mes->z_t[0], pss_mes->z_t[1], pss_mes->z_t[2]);
Everything was fine until I wanted to see the size of my list measuresQueuewith the: cout << "measuresQueue. size: " << measuresQueue.size() << '\n';
I always get the number 4 instead of ten. I don't know what is the reason?
Thank you,
M.