Ransom Conant / Mbed 2 deprecated MbedPacman

Dependencies:   4DGL-uLCD-SE mbed wave_player

Fork of PacMan_Skeleton_unlock by ECE 2035 TA

Embed: (wiki syntax)

« Back to documentation index

doubly_linked_list.h File Reference

doubly_linked_list.h File Reference

Go to the source code of this file.

Data Structures

struct  llnode_t
 The structure to store the information of a doubly linked list node. More...
struct  dlinkedlist_t
 The structure to store the information of a doubly linked list. More...

Typedefs

typedef struct llnode_t LLNode
 The structure to store the information of a doubly linked list node.
typedef struct dlinkedlist_t DLinkedList
 The structure to store the information of a doubly linked list.

Functions

DLinkedListcreate_dlinkedlist (void)
 create_dlinkedlist
void insertHead (DLinkedList *dLinkedList, void *data)
 InsertHead.
void insertTail (DLinkedList *dLinkedList, void *data)
 insertTail
int insertAfter (DLinkedList *dLinkedList, void *newData)
 insertAfter
int insertBefore (DLinkedList *dLinkedList, void *newData)
 insertBefore
void * deleteBackward (DLinkedList *dLinkedList)
 deleteBackward
void * deleteForward (DLinkedList *dLinkedList)
 deleteForward
void destroyList (DLinkedList *dLinkedList)
 destroyList
void * getHead (DLinkedList *dLinkedList)
 getHead
void * getTail (DLinkedList *dLinkedList)
 getTail
void * getCurrent (DLinkedList *dLinkedList)
 getCurrent
void * getNext (DLinkedList *dLinkedList)
 getNext
void * getPrevious (DLinkedList *dLinkedList)
 getPrevious
int getSize (DLinkedList *dLinkedList)
 getSize

Detailed Description

Definition in file doubly_linked_list.h.


Typedef Documentation

typedef struct dlinkedlist_t DLinkedList

The structure to store the information of a doubly linked list.

typedef struct llnode_t LLNode

The structure to store the information of a doubly linked list node.


Function Documentation

DLinkedList* create_dlinkedlist ( void   )

create_dlinkedlist

Creates a doubly liked list by allocating memory for it on the heap. Initialize the size to 0, as well as head, current, and tail pointer to NULL

Returns:
A pointer to an empty dlinkedlist

Definition at line 5 of file doubly_linked_list.cpp.

void* deleteBackward ( DLinkedList dLinkedList )

deleteBackward

Delete the node the current pointer is pointed at, and move the current pointer backwards. Be aware that deleteBackward will cause problem if the current pointer is pointing at list head (new head should be current->next, while the current pointer points at NULL)

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the data of the new current pointer and NULL if the current pointer is NULL

Definition at line 96 of file doubly_linked_list.cpp.

void* deleteForward ( DLinkedList dLinkedList )

deleteForward

Delete the node the current pointer is pointed at, and move the current pointer forwards. Be aware that deleteForward will cause problem if the current pointer is pointing at list tail

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the data of the new current pointer and NULL if the current pointer is NULL

Definition at line 137 of file doubly_linked_list.cpp.

void destroyList ( DLinkedList dLinkedList )

destroyList

Destroy the doubly linked list. Everything in the linked list including list structure, nodes and data are all freed from the heap

Parameters:
dLinkedListA pointer to the doubly linked list

Definition at line 177 of file doubly_linked_list.cpp.

void* getCurrent ( DLinkedList dLinkedList )

getCurrent

Return the data the current pointer is pointing at

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the current data or NULL if current == NULL

Definition at line 212 of file doubly_linked_list.cpp.

void* getHead ( DLinkedList dLinkedList )

getHead

Return the data contained in the head of the doubly linked list, and set the list current pointer to head

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the head data or NULL if head == NULL

Definition at line 187 of file doubly_linked_list.cpp.

void* getNext ( DLinkedList dLinkedList )

getNext

Return the next data the current pointer is pointing at, and move the current pointer to next node

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the next data or NULL if current == NULL

Definition at line 223 of file doubly_linked_list.cpp.

void* getPrevious ( DLinkedList dLinkedList )

getPrevious

Return the previous data the current pointer is pointing at, and move the current pointer to previous node

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the previous data or NULL if current == NULL

Definition at line 235 of file doubly_linked_list.cpp.

int getSize ( DLinkedList dLinkedList )

getSize

Return the size of the doubly linked list

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the size

Definition at line 246 of file doubly_linked_list.cpp.

void* getTail ( DLinkedList dLinkedList )

getTail

Return the data contained in the tail of the doubly linked list, and set the current pointer to tail

Parameters:
dLinkedListA pointer to the doubly linked list
Returns:
the tail data or NULL if tail == NULL

Definition at line 200 of file doubly_linked_list.cpp.

int insertAfter ( DLinkedList dLinkedList,
void *  newData 
)

insertAfter

Insert the new data to the doubly linked list right after the current pointer

Parameters:
dLinkedListA pointer to the doubly linked list
newDataA void pointer to the new data that the user want to add after data
Returns:
1 if insert the new data successfully 0 if the current pointer is NULL

Definition at line 51 of file doubly_linked_list.cpp.

int insertBefore ( DLinkedList dLinkedList,
void *  newData 
)

insertBefore

Insert the new data to the doubly linked list right before the current pointer

Parameters:
dLinkedListA pointer to the doubly linked list
newDataA void pointer to the new data that the user want to add after data
Returns:
1 if insert the new data successfully 0 if the current pointer is NULL

Definition at line 73 of file doubly_linked_list.cpp.

void insertHead ( DLinkedList dLinkedList,
void *  data 
)

InsertHead.

Insert the data to the head of the doubly linked list. Attention: All insert functions do not make change on the current pointer.

Parameters:
dLinkedListA pointer to the doubly linked list
dataA void pointer to data the user is adding to the doubly linked list.

Definition at line 22 of file doubly_linked_list.cpp.

void insertTail ( DLinkedList dLinkedList,
void *  data 
)

insertTail

Insert the data to the tail of the doubly linked list.

Parameters:
dLinkedListA pointer to the doubly linked list
dataA void pointer to data the user is adding to the doubly linked list.

Definition at line 37 of file doubly_linked_list.cpp.