modified: src/llist.c

modified:   src/llist.h
sql
simon 2024-12-11 11:01:37 +01:00
parent 9b98291c1e
commit ca5065d569
2 changed files with 7 additions and 3 deletions

View File

@ -26,7 +26,7 @@ llist *llistTail(llist *l) {
return tail;
}
/* creates new node from data and appends it to head
/* creates new node from data and appends it to tail
*
*/
llist *llistAppend(llist *head, void *data) {
@ -41,7 +41,10 @@ llist *llistAppend(llist *head, void *data) {
return new;
}
void *llistGet(llist *head, void *key) {
/*
* return Node containing key or NULL
*/
llist *llistGet(llist *head, void *key) {
llist *c = head;
while (c != NULL) {
if (key == c) {
@ -51,6 +54,7 @@ void *llistGet(llist *head, void *key) {
}
return NULL;
}
bool llistContains(llist *head, void *key) {
return llistGet(head, key) != NULL;
}

View File

@ -14,7 +14,7 @@ llist *llistNew(void *data, int (*cmpFN)(void *a, void *b));
// create new node with data and append to tail of head
llist *llistAppend(llist *head, void *data);
// return llistNode that contains key or NULL
void *llistGet(llist *head, void *key);
llist *llistGet(llist *head, void *key);
// TURE if llist contains key
bool llistContains(llist *head, void *key);
// free llist node (Does Not free data it contains!!)