TP1: Presentation

This commit is contained in:
augustin64 2024-03-31 18:26:34 +02:00
parent ce8fd5f3a5
commit ecef2540bc

View File

@ -29,7 +29,7 @@ void insertFirst(linkedList *list, int key, void *data) {
//delete first item //delete first item
node* deleteFirst(linkedList *list) { node* deleteFirst(linkedList *list) {
if (list->head == NULL) { if (!list->head) {
return NULL; return NULL;
} }
@ -50,7 +50,7 @@ node* find(linkedList *list, int key) {
node* current = list->head; node* current = list->head;
//if list is empty //if list is empty
if(list->head == NULL) { if(!current) {
return NULL; return NULL;
} }
@ -58,7 +58,7 @@ node* find(linkedList *list, int key) {
while(current->key != key) { while(current->key != key) {
//if it is last node //if it is last node
if(current->next == NULL) { if(!current->next) {
return NULL; return NULL;
} else { } else {
//go to next link //go to next link
@ -78,7 +78,7 @@ node* deleteElement(linkedList *list, int key) {
node* previous = NULL; node* previous = NULL;
//if list is empty //if list is empty
if(list->head == NULL) { if(!list->head) {
return NULL; return NULL;
} }
@ -86,7 +86,7 @@ node* deleteElement(linkedList *list, int key) {
while(current->key != key) { while(current->key != key) {
//if it is last node //if it is last node
if(current->next == NULL) { if(!current->next) {
return NULL; return NULL;
} else { } else {
//store reference to current link //store reference to current link
@ -110,7 +110,7 @@ node* deleteElement(linkedList *list, int key) {
//is list empty //is list empty
bool isEmpty(linkedList *list) { bool isEmpty(linkedList *list) {
return list->head == NULL; return !list->head;
} }
int length(linkedList *list) { int length(linkedList *list) {