Hi,
I tried to use the STL list in order to insert and erase some element, =
but if I look to the memory usage of my program it seems when I erase =
elements the memory occupation it is the same (also if I use clear()).
This code is an example=20
#include <iostream>
#include <list>
#include <cstdlib>
using namespace std;
class prova
{
public:
int x,y;
prova(int X, int Y):x(X),y(Y){}
};
int main()
{
list <prova> lista;
for (int i=3D0;i<1000000;i++){
prova *temp=3D new prova(rand()%2,i);
lista.push_back(*temp);}
list<prova>::iterator t;
t=3Dlista.begin();
while (t!=3Dlista.end())
{
if (t->x=3D=3D0) =20
t=3Dlista.erase(t);
else
t++;
}
lista.clear();
system("PAUSE");
return 0;
}
Some suggestions?
Thanks in advance:
Alessandro |