StudyPlanner/src/llist.h

24 lines
681 B
C
Raw Normal View History

#ifndef LLIST
#define LLIST
#include <stdbool.h>
typedef struct llist {
void *data;
struct llist *next;
struct llist *prev;
int (*cmpFn)(void *a, void *b); // function that compares data
} llist;
// create new linked list with content(void* data) and cmpFN
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
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!!)
void llistFree(llist *head);
#endif