Byron Pritchett Jr / Mbed 2 deprecated MC_Summer_shell

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
lwills
Date:
Wed Jun 24 21:09:03 2020 +0000
Revision:
0:09aa1ecd6c39
Child:
1:5724f2947554
Missile Command shell

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lwills 0:09aa1ecd6c39 1 //=================================================================
lwills 0:09aa1ecd6c39 2 // Header file for DLL module.
lwills 0:09aa1ecd6c39 3 //
lwills 0:09aa1ecd6c39 4 // Copyright 2020 Georgia Tech. All rights reserved.
lwills 0:09aa1ecd6c39 5 // The materials provided by the instructor in this course are for
lwills 0:09aa1ecd6c39 6 // the use of the students currently enrolled in the course.
lwills 0:09aa1ecd6c39 7 // Copyrighted course materials may not be further disseminated.
lwills 0:09aa1ecd6c39 8 // This file must not be made publicly available anywhere.
lwills 0:09aa1ecd6c39 9 //=================================================================
lwills 0:09aa1ecd6c39 10
lwills 0:09aa1ecd6c39 11 #ifndef DOUBLELINKEDLIST_H
lwills 0:09aa1ecd6c39 12 #define DOUBLELINKEDLIST_H
lwills 0:09aa1ecd6c39 13
lwills 0:09aa1ecd6c39 14 // A linked list node structure.
lwills 0:09aa1ecd6c39 15 typedef struct llnode_t {
lwills 0:09aa1ecd6c39 16 void* data;
lwills 0:09aa1ecd6c39 17 struct llnode_t* prev;
lwills 0:09aa1ecd6c39 18 struct llnode_t* next;
lwills 0:09aa1ecd6c39 19 }LLNode;
lwills 0:09aa1ecd6c39 20
lwills 0:09aa1ecd6c39 21 /// The structure to store the information of a doubly linked list
lwills 0:09aa1ecd6c39 22 typedef struct dlinkedlist_t {
lwills 0:09aa1ecd6c39 23 struct llnode_t* head;
lwills 0:09aa1ecd6c39 24 struct llnode_t* tail;
lwills 0:09aa1ecd6c39 25 int size;
lwills 0:09aa1ecd6c39 26 } DLinkedList;
lwills 0:09aa1ecd6c39 27
lwills 0:09aa1ecd6c39 28 // Used for testing.
lwills 0:09aa1ecd6c39 29 struct LLItem {};
lwills 0:09aa1ecd6c39 30 void testDLL(void);
lwills 0:09aa1ecd6c39 31
lwills 0:09aa1ecd6c39 32 /**
lwills 0:09aa1ecd6c39 33 * create_llnode
lwills 0:09aa1ecd6c39 34 *
lwills 0:09aa1ecd6c39 35 * Creates a node by allocating memory for it on the heap,
lwills 0:09aa1ecd6c39 36 * and initializing its previous and next pointers to NULL and its data pointer to the input
lwills 0:09aa1ecd6c39 37 * data pointer
lwills 0:09aa1ecd6c39 38 *
lwills 0:09aa1ecd6c39 39 * @param data A void pointer to data the user is adding to the doublely linked list.
lwills 0:09aa1ecd6c39 40 * @return A pointer to the linked list node
lwills 0:09aa1ecd6c39 41 */
lwills 0:09aa1ecd6c39 42 LLNode* create_llnode(void* data);
lwills 0:09aa1ecd6c39 43
lwills 0:09aa1ecd6c39 44 /**
lwills 0:09aa1ecd6c39 45 * create_dlinkedlist
lwills 0:09aa1ecd6c39 46 *
lwills 0:09aa1ecd6c39 47 * Creates a doubly linked list by allocating memory for it on the heap. Initialize the size to zero,
lwills 0:09aa1ecd6c39 48 * as well as head and tail pointers to NULL
lwills 0:09aa1ecd6c39 49 *
lwills 0:09aa1ecd6c39 50 * @return A pointer to an empty dlinkedlist
lwills 0:09aa1ecd6c39 51 */
lwills 0:09aa1ecd6c39 52 DLinkedList* create_dlinkedlist(void);
lwills 0:09aa1ecd6c39 53
lwills 0:09aa1ecd6c39 54
lwills 0:09aa1ecd6c39 55 /**
lwills 0:09aa1ecd6c39 56 * InsertHead
lwills 0:09aa1ecd6c39 57 *
lwills 0:09aa1ecd6c39 58 * Create a new LLNode with the given data and insert it at the head of the doubly linked list.
lwills 0:09aa1ecd6c39 59 * Be sure to update the list's size, head (and tail if necessary).
lwills 0:09aa1ecd6c39 60 *
lwills 0:09aa1ecd6c39 61 * @param dLinkedList A pointer to the doubly linked list
lwills 0:09aa1ecd6c39 62 * @param data A void pointer to data the user is adding to the doubly linked list.
lwills 0:09aa1ecd6c39 63 *
lwills 0:09aa1ecd6c39 64 */
lwills 0:09aa1ecd6c39 65 void insertHead(DLinkedList* dLinkedList, void* data);
lwills 0:09aa1ecd6c39 66
lwills 0:09aa1ecd6c39 67 /**
lwills 0:09aa1ecd6c39 68 * deleteNode
lwills 0:09aa1ecd6c39 69 *
lwills 0:09aa1ecd6c39 70 * Delete the node pointed to by Node (splice it out). Update list head/tail if necessary.
lwills 0:09aa1ecd6c39 71 * Update the list's size. Free the Node's data and Node.
lwills 0:09aa1ecd6c39 72 * Assume Node is not NULL.
lwills 0:09aa1ecd6c39 73 *
lwills 0:09aa1ecd6c39 74 * @param dLinkedList A pointer to the doubly linked list
lwills 0:09aa1ecd6c39 75 * @param Node A pointer to a linked list node.
lwills 0:09aa1ecd6c39 76 */
lwills 0:09aa1ecd6c39 77 void deleteNode(DLinkedList* dLinkedList, LLNode* Node);
lwills 0:09aa1ecd6c39 78
lwills 0:09aa1ecd6c39 79
lwills 0:09aa1ecd6c39 80 /**
lwills 0:09aa1ecd6c39 81 * destroyList
lwills 0:09aa1ecd6c39 82 *
lwills 0:09aa1ecd6c39 83 * Destroy the doubly linked list. Everything in the linked list including list structure,
lwills 0:09aa1ecd6c39 84 * nodes and data are all freed from the heap
lwills 0:09aa1ecd6c39 85 *
lwills 0:09aa1ecd6c39 86 * @param dLinkedList A pointer to the doubly linked list
lwills 0:09aa1ecd6c39 87 *
lwills 0:09aa1ecd6c39 88 */
lwills 0:09aa1ecd6c39 89 void destroyList(DLinkedList* dLinkedList);
lwills 0:09aa1ecd6c39 90
lwills 0:09aa1ecd6c39 91 /**
lwills 0:09aa1ecd6c39 92 * getSize
lwills 0:09aa1ecd6c39 93 *
lwills 0:09aa1ecd6c39 94 * Return the size of the doubly linked list
lwills 0:09aa1ecd6c39 95 *
lwills 0:09aa1ecd6c39 96 * @param dLinkedList A pointer to the doubly linked list
lwills 0:09aa1ecd6c39 97 * @return the size
lwills 0:09aa1ecd6c39 98 */
lwills 0:09aa1ecd6c39 99 int getSize(DLinkedList* dLinkedList);
lwills 0:09aa1ecd6c39 100 #endif
lwills 0:09aa1ecd6c39 101