Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Liste::supprimeIemeElement(unsigned int x) // my function wants to delete the Xth element of a chained list
- {
- Cellule * temp1; // My chained list is composed by "Cellule"
- temp1 = prem; // prem is the first "Cellule" of my chained list
- unsigned int i;
- i = 1;
- while (temp1 != NULL && i <= x)
- {
- if (x == i)
- {
- if (temp1->suivant == NULL)
- {
- supprimerQueue(); // function that delete the last elemnt of my chained list; works
- }
- else if (temp1->precedent == NULL)
- {
- supprimerTete (); // function that delete the first element of my chained list; also works
- }
- else
- {
- temp1->suivant->precedent = temp1->precedent; // "precedent" is for the next element
- temp1->precedent->suivant = temp1->suivant; // "suivant" is for the next one
- }
- delete temp1; // <--- here i want to delete the #i elemnt of my list but i think theres a problem here
- }
- else
- {
- temp1 = temp1->suivant;
- }
- i = i + 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement