17 #ifndef LL_IS_ARRAY_BACKED 22 #define MAX_NUM_OF_LL_NODES 256 51 #ifdef LL_IS_ARRAY_BACKED 66 int (*searchCompFunc)(
void*,
void*);
67 int (*insertCompFunc)(
void*,
void*);
68 int (*freeNodeFunc)(
node_t *nodeToFree);
69 void (*printNodeFunc)(
void*);
71 #ifdef LL_IS_ARRAY_BACKED 72 unsigned int numNodesInUse;
81 #define VARIABLE_LL_LENGTH(LIST_LENGTH) { \ 82 typedef struct s_ll_##LIST_LENGTH##_t linkedList_##LIST_LENGTH##_t \ 83 struct s_ll_##LIST_LENGTH##_t \ 87 int (*searchCompFunc)(void*, void*); \ 88 int (*comparisonFunc)(void*, void*); \ 89 int (*freeNodeFunc)(node_t *nodeToFree); \ 90 void (*printList)(void*); \ 92 unsigned int numNodesInUse; \ 93 node_t backingArray[LIST_LENGTH]; \ 230 #endif // LINKEDLIST_H
typedef of linked list node (see s_ll_node).
void setPrintFunction(linkedList_t *list, void(*newPrintFunc)(void *))
sets the function whose job it is to print the list to the screen.
void setSearchComparisonFunction(linkedList_t *list, int(*newSearchFunc)(void *, void *))
sets the function whose job it is to compare the input data with the data in the list. the first void parameter will always be the data contained in the list, the second will be the data passed to the search function.
node_t * removeNode(node_t *nodeToRemove)
will remove the node from the list. the list hierarchy will change to reflect the missing node...
void initLinkedList(linkedList_t *list)
initilize list and the optional array that backs the list
typedef of linked list (see s_ll).
node_t * insertAfterNode(node_t *preceedingNode, node_t *newNode)
insert a node into the parent list of the preceedingNode after preceedingNode
node_t * moveNodeToNewList(node_t *nodeToMove, linkedList_t *newList)
If a node needs to move lists and lists are array backed, instead of just moving preceeding and sucee...
void printList(linkedList_t *list)
test function to show list functionality. uses const char* as test data
node_t * makeNewNode(linkedList_t *list, void *data)
get new node, allocate a new node or find an unused node from the list's pool
void setInsertComparisonFunction(linkedList_t *list, int(*newCompFunc)(void *, void *))
takes in a function pointer and sets the library shared comparison pointer
struct definition for the linked list
node_t * insertNode(linkedList_t *list, node_t *newNode)
Will insert the node into the list. This function will attempt to call the list's insert comparison f...
#define MAX_NUM_OF_LL_NODES
struct for a node of the linked list
void setFreeFunction(linkedList_t *list, int(*newFreeFunc)(node_t *))
sets the function whose job it is to free the node's memory
node_t * searchList(linkedList_t *listToSearch, void *data)
goes through the list using the list's comparison function to find the node which matches the data...
void listTest()
test the linked_list class with const char* data and output to screen the results of the test ...
node_t * insertBeforeNode(node_t *nodeToFollow, node_t *newNode)
insert a node into the parent list of the nodeToFollow before nodeToFollow