parent
9b98291c1e
commit
ca5065d569
|
@ -26,7 +26,7 @@ llist *llistTail(llist *l) {
|
||||||
return tail;
|
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) {
|
llist *llistAppend(llist *head, void *data) {
|
||||||
|
@ -41,7 +41,10 @@ llist *llistAppend(llist *head, void *data) {
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *llistGet(llist *head, void *key) {
|
/*
|
||||||
|
* return Node containing key or NULL
|
||||||
|
*/
|
||||||
|
llist *llistGet(llist *head, void *key) {
|
||||||
llist *c = head;
|
llist *c = head;
|
||||||
while (c != NULL) {
|
while (c != NULL) {
|
||||||
if (key == c) {
|
if (key == c) {
|
||||||
|
@ -51,6 +54,7 @@ void *llistGet(llist *head, void *key) {
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool llistContains(llist *head, void *key) {
|
bool llistContains(llist *head, void *key) {
|
||||||
return llistGet(head, key) != NULL;
|
return llistGet(head, key) != NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// create new node with data and append to tail of head
|
||||||
llist *llistAppend(llist *head, void *data);
|
llist *llistAppend(llist *head, void *data);
|
||||||
// return llistNode that contains key or NULL
|
// return llistNode that contains key or NULL
|
||||||
void *llistGet(llist *head, void *key);
|
llist *llistGet(llist *head, void *key);
|
||||||
// TURE if llist contains key
|
// TURE if llist contains key
|
||||||
bool llistContains(llist *head, void *key);
|
bool llistContains(llist *head, void *key);
|
||||||
// free llist node (Does Not free data it contains!!)
|
// free llist node (Does Not free data it contains!!)
|
||||||
|
|
Loading…
Reference in New Issue