Revert "Return deleted element from List_remove()"

main
Hammy 3 years ago
parent 00819f6edc
commit 58822a8565

@ -98,13 +98,12 @@ int List_remove(List *list, int element) {
return ERRNO_005;
}
int elementToDelete = list->_array[positionToDelete];
for (int i = positionToDelete; i < list->_currentSize; i++) {
list->_array[i] = list->_array[i + 1];
}
list->_currentSize--;
return elementToDelete;
return 0;
}
int List_sort(List *list, bool reverse) {

@ -107,7 +107,7 @@ int List_insert(List *list, int index, int element);
*
* Returns
* ----------------------------
* int (The deleted element)
* int (0 for success, Non-0 for error)
*/
int List_remove(List *list, int element);

@ -147,10 +147,9 @@ void shouldRemoveElementFromList() {
List_append_all(list, 4, 0, 1, 2, 0);
// Act
int deletedElement = List_remove(list, 0);
List_remove(list, 0);
// Assert
assert(deletedElement == 0);
assert(List_length(list) == 3);
assert(List_get(list, 0) == 1);
assert(List_get(list, 1) == 2);

Loading…
Cancel
Save