/******************************************
*
* Cedric Pradalier 2001
* mail : http://cedric.pradalier.free.fr/mail.html
*
*****************************************/
#include "Object.h"
#include "Vector.h"
#include <stdlib.h>
#include <stdio.h>
class LongInt : public Object
{
private :
long int l;
public :
LongInt(long int i) {l = i;}
~LongInt() {}
void Print() {printf("%ld",l);}
double Value() {return (double)(l);}
};
int main()
{
Vector v;
int j;
for (j=0;j<24;j++)
{
v.addElement(new LongInt(lrand48()%1000));
}
printf("\nInsertion de 24 nbs aleatoires\n");
v.Print();
v.sort();
printf("\nApres Tri :\n");
v.Print();
printf("\nSuppression d'un élément sur 2.\n");
printf("\tLa suppression ne conserve pas l'ordre\n");
printf("\tLes objects ne sont pas détruits lors de la suppression, \n\tseulement supprimés du tableau\n");
for (j=23;j>=0;j-=2)
{
delete v[j];
v.deleteElement(j);
}
v.Print();
printf("\nDestruction de tous les éléments\n");
v.deleteAll();
v.Print();
printf("\nTerminé\n");
}