60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
#include "exo1.c"
|
|
|
|
itr creer_ilc_itr(int estimation_capacite) {
|
|
return creer_itr(estimation_capacite*2);
|
|
}
|
|
void inserer_ilc_itr(itr* t, int indice, int x) {
|
|
int n = taille_itr(*t);
|
|
if (taille_itr(*t) == 0) {
|
|
append_itr(t, x);
|
|
} else {
|
|
int tmp;
|
|
while (indice < n) {
|
|
tmp = acces_itr(*t, indice);
|
|
modif_itr(*t, indice, x);
|
|
indice++;
|
|
x = tmp;
|
|
}
|
|
append_itr(t, tmp);
|
|
}
|
|
}
|
|
void retirer_ilc_itr(itr* t, int indice) {
|
|
int x = pop_itr(t);
|
|
for (int i = taille_itr(*t)-1; i >= indice; i--) {
|
|
int tmp = acces_itr(*t, i);
|
|
modif_itr(*t, i, tmp);
|
|
x = tmp;
|
|
}
|
|
}
|
|
int acceder_ilc_itr(itr t, int indice) {
|
|
return acces_itr(t, indice);
|
|
}
|
|
void modifier_ilc_itr(itr t, int indice, int x) {
|
|
modif_itr(t, indice, x);
|
|
}
|
|
void inserer_tete_ilc_itr(itr* t, int x) {
|
|
inserer_ilc_itr(t, 0, x);
|
|
}
|
|
int retirer_tete_ilc_itr(itr* t) {
|
|
int x = acces_itr(*t, 0);
|
|
retirer_ilc_itr(t, 0);
|
|
return x;
|
|
}
|
|
void inserer_fond_ilc_itr(itr* t, int x) {
|
|
if (taille_itr(*t) == 0) {
|
|
append_itr(t, x);
|
|
} else {
|
|
inserer_ilc_itr(t, taille_itr(*t)-1, x);
|
|
}
|
|
}
|
|
int retirer_fond_ilc_itr(itr* t) {
|
|
int x;
|
|
if (taille_itr(*t) == 0) {
|
|
x = pop_itr(t);
|
|
} else {
|
|
x = acces_itr(*t, taille_itr(*t)-1);
|
|
retirer_ilc_itr(t, taille_itr(*t)-1);
|
|
}
|
|
return x;
|
|
}
|