From dcfa51f9382b0291633be7f8df1fc87334b67300 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Tue, 9 Apr 2019 16:09:37 -0400 Subject: [PATCH] Update list.h Adding documentation --- src/util/list.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/util/list.h b/src/util/list.h index f19b7d4..6bc47e7 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -40,15 +40,49 @@ typedef struct { } list_t; +/** +@brief Initializes a linked list to store elements of elementSize and to call +freeFunction for each element when destroying a list. +*/ list_t *create_list(int elementSize, freeFunction freeFn); + +/** +@brief Frees dynamically allocated nodes and optionally calls freeFunction +with each node’s data pointer. +*/ void delete_list(list_t *list); +/** +@brief Adds a node to the head of the list. +*/ void prepend_list(list_t *list, void *element); + +/** +@brief Adds a node to the tail of the list. +*/ void append_list(list_t *list, void *element); + +/** +@brief Returns the number of items in the list. +*/ int size_list(list_t *list); + +/** +@brief Calles the supplied iterator function with the data element of each +node (iterates over the list). +*/ void for_each_list(list_t *list, listIterator iterator); + +/** +@brief Returns the head of the list (optionally removing it at the same time). +*/ void head_list(list_t *list, void *element, bool removeFromList); + + +/** +@brief Returns the tail of the list. +*/ void tail_list(list_t *list, void *element);