diff options
Diffstat (limited to 'src/LinkedList.h')
| -rw-r--r-- | src/LinkedList.h | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/LinkedList.h b/src/LinkedList.h deleted file mode 100644 index 363fb21..0000000 --- a/src/LinkedList.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef LINKEDLIST_H -#define LINKEDLIST_H - -// A linked list containing any type of pointer. -// The linked list does _not_ own its elements. - -typedef struct LinkedList LinkedList; -typedef struct LinkedListNode LinkedListNode; - -struct LinkedList { - LinkedListNode *head; - LinkedListNode *tail; - int size; -}; - -struct LinkedListNode { - LinkedListNode *next; - LinkedListNode *prev; - void *data; -}; - -// Allocate and initialize an empty linked list. -// Returns: a pointer to the new linked list, or NULL on error. -// Post: the caller owns the linked list. -LinkedList *linkedlist_new(); - -// Deallocate the given linked list, including all nodes -// (but _not_ the data they point to, the user owns that). -void linkedlist_delete(LinkedList *ll); - -// Append a the given element to the list. -// The linked list does _not_ take ownership over the element -// (only the linked list node). -// Returns: a pointer to the node with the new element, or NULL on error. -LinkedListNode *linkedlist_append(LinkedList *ll, void *elem); - -// Remove and return the first element from the given list. -// Pre: ll->size != 0 -void *linkedlist_popfront(LinkedList *ll); - -// Find the linked list node containing the given element. -// Returns: a pointer to the found node, or NULL if the element was not found. -LinkedListNode *linkedlist_find(LinkedList *ll, void *elem); - -// Remove the given node from the given linked list (and deallocate it). -// Pre: node must belong to ll -// Returns: node->data -void *linkedlist_remove(LinkedList *ll, LinkedListNode *node); - -#endif // LINKEDLIST_H |