C++ (Qt)void TStruct::DeleteElement(const Array &Element, int j){ if (j < 0 || j >= Count) { qDebug() << "index out of bounds"; return; } Zveno *elementToDelete = Head; for (int i = 0; i < j; ++i) elementToDelete = elementToDelete->Next; elementToDelete->Prev->Next = elementToDelete->Next; elementToDelete->Next->Prev = elementToDelete->Prev; delete elementToDelete; --Count;}
void TStruct::DeleteElement(int j){ if (j<0||j>Count){ qDebug()<<"Index out of range"; return; } Zveno *temp; Zveno *Current=Head; for(int i=1;i<j&&Current!=NULL;i++)Current=Current->Next; if (Current != NULL){ if (Current == Head){ //удаляем первый элемент Head = Head->Next; delete(Current); Current = Head; }else{ //удаляем не первый элемент temp=Head; while(temp->Next!=Current)temp=temp->Next; temp->Next=Current->Next; delete (Current); Current=temp; } } --Count;}