Question: Using typedef struct Node{ void* data; struct Node* next; struct Node* prev; } Node; typedef struct LList{ Node* first; Node* last; int size; int itemSize;
Using
typedef struct Node{
void* data;
struct Node* next;
struct Node* prev;
} Node;
typedef struct LList{
Node* first;
Node* last;
int size;
int itemSize;
char* type;
} LinkedList;
which correlate to

create functions




C Programming
Structure Name Fields Functionality Node (typedef Node) void* data The data held by this node. struct _Node* next The node after the current node in the linked list. struct _Node* prev The node before the current node in the linked list. LList (typedef LinkedList) Node* first A pointer to the first node in the list. Node* last A pointer to the last node in the list. int size The current number of nodes (items) held by this linked list. int itemSize The size of the data type held by this linked list in bytes. char* type The name of the data type held by this linked list as a string. Requirement Function Input Parameters Return Value Notes Conditions LinkedList* llist_initialize(int, char*) An integer for setting the data type size and a string representing the name of the data type being stored. An initialized linked list. An initialized linked list will have the size, item size, and type set. It will not have a node attached, so the first and last pointers should be set to NULL. Conditions bool llist_add_at(LinkedList*, int, void*) A pointer to a linked list, an integer index, and a void pointer to an element. True if the element was successfully added to the linked list at the given index. Otherwise false. This function should insert the given element at the given index in the linked list. Requirement Function Input Parameters Return Value Notes Requirement Conditions Function bool llist_add first (Linked List*, void*) Input Parameters A pointer to a linked list and a void pointer to an element. Return Value True if the element was successfully added to the front of the linked list. Otherwise false. Notes This function should insert the given element on the front of the linked list. Requirement Conditions Function bool llist_add_last(Linked List*, void*) Input Parameters A pointer to a linked list and a void pointer to an element. Return Value True if the element was successfully added to the end of the linked list. Otherwise false. Notes This function should insert the given element on the end of the linked list. Requirement Conditions Function void* llist_get(Linked List*, int) Input Parameters A pointer to a linked list and an int representing an index. Return Value A void pointer to the element stored in the given index of the linked list. If the given index is not in the list range, return NULL. Notes This function should return the void pointer stored in the given index of the linked. This should not return a whole Node, but instead the value the node contains as data. Requirement Function Input Parameters Return Value Notes Requirement Function Input Parameters Return Value Notes Requirement Function Input Parameters Return Value Notes Conditions int llist_index_of(Linked List*, void*) A pointer to a linked list and a void pointer to an element. The index containing the element. -1 if the element is not in the list. This function should search the linked list for the element and return its index if found. Conditions void* llist_remove(Linked List*, int) A pointer to a linked list and an int representing an index. A pointer to the element removed from the list. Otherwise NULL. This function should remove the element in the given index from the list and return it. Conditions void* llist_remove_first (Linked List*) A pointer to a linked list. A pointer to the element removed from the list. Otherwise NULL. This function should remove the element from the front of the list and return it. Requirement Function Input Parameters Return Value Notes Requirement Function Input Parameters Return Value Notes Conditions void* llist_remove_last (Linked List*) A pointer to a linked list. A pointer to the element removed from the list. Otherwise NULL. This function should remove the element from the list and return it. Conditions bool llist_destroy(Linked List*) A pointer to a linked list. True if the linked list is successfully deallocated. Otherwise false. This function should deallocate all of the nodes, all of the node data, the type name, and finally the linked list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
