Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __LINKEDLIST_H__
- #define __LINKEDLIST_H__
- #include <stdbool.h>
- /*
- * The user of this class is responsible for cleaning up the memory used by any data used by this class
- */
- struct llnode {
- void* data;
- struct llnode* next;
- struct llnode* prev;
- };
- struct linkedlist {
- int size;
- struct llnode* head;
- struct llnode* tail;
- };
- struct linkedlist linkedlist_create();
- // returns false if we cannot allocate memory for the internal linked list node
- bool linkedlist_insert(struct linkedlist* ll, void* data);
- // remove is a wrapper for removehead
- void* linkedlist_remove(struct linkedlist* ll);
- void* linkedlist_removetail(struct linkedlist* ll);
- void* linkedlist_removehead(struct linkedlist* ll);
- inline int linkedlist_getsize(struct linkedlist* ll);
- // calls memfree to free given data; memfree may be NULL
- void linkedlist_destroy(struct linkedlist* ll, void(*memfree)(void*));
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement