ECE 2036 Project

Dependencies:   mbed wave_player 4DGL-uLCD-SE

Embed: (wiki syntax)

« Back to documentation index

<title>doublely_linked_list.h File Reference</title>

doublely_linked_list.h File Reference

Go to the source code of this file.

Data Structures

struct  dlinkedlist_t
 This structure represents an entire linked list. More...
struct  llnode_t
 This structure represents a single list node. More...

Typedefs

typedef struct dlinkedlist_t DLinkedList
 This structure represents an entire linked list.
typedef struct llnode_t LLNode
 This structure represents a single list node.

Functions

DLinkedListcreate_dlinkedlist (void)
 create_dlinkedlist
LLNodecreate_llnode (void *data)
 create_llnode
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 * removeBackward (DLinkedList *dLinkedList)
 removeBackward
void * removeForward (DLinkedList *dLinkedList)
 removeForward
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 doublely_linked_list.h.


Typedef Documentation

typedef struct dlinkedlist_t DLinkedList

This structure represents an entire linked list.

typedef struct llnode_t LLNode

This structure represents a single list node.


Function Documentation

DLinkedList* create_dlinkedlist ( void   )

create_dlinkedlist

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

Returns:
A pointer to an empty dlinkedlist

Definition at line 5 of file doublely_linked_list.cpp.

LLNode* create_llnode ( void *  data )

create_llnode

Helper function that creates a node by allocating memory for it on the heap, and initializing its previous and next pointers to NULL and its data pointer to the input data pointer

Parameters:
dataA void pointer to data the user is adding to the doublely linked list.
Returns:
A pointer to the linked list node

Definition at line 21 of file doublely_linked_list.cpp.

void* deleteBackward ( DLinkedList dLinkedList )

deleteBackward

Delete the node the current pointer is pointed at, and move the current pointer backward. Be aware that deleteBackward will cause problems if the current node is the list head, or if the current node is the only node in the list. In these cases, the current pointer should be set to NULL after deleting the node, and the list head and tail pointers should be updated appropriately.

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

Definition at line 137 of file doublely_linked_list.cpp.

void* deleteForward ( DLinkedList dLinkedList )

deleteForward

Delete the node the current pointer is pointed at, and move the current pointer forward. Be aware that deleteForward will cause problems if the current node is the list tail, or if the current node is the only node in the list. In these cases, the current pointer should be set to NULL after deleting the node, and the list head and tail pointers should be updated appropriately.

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

Definition at line 177 of file doublely_linked_list.cpp.

void destroyList ( DLinkedList dLinkedList )

destroyList

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

Parameters:
dLinkedListA pointer to the doublely linked list
shouldFreeFlag. 1 indicates if data should be freed upon deletion of node.

Definition at line 285 of file doublely_linked_list.cpp.

void* getCurrent ( DLinkedList dLinkedList )

getCurrent

Return the data the current pointer is pointing at

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

Definition at line 334 of file doublely_linked_list.cpp.

void* getHead ( DLinkedList dLinkedList )

getHead

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

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

Definition at line 300 of file doublely_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. If the current pointer is at the tail, the next node is NULL.

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

Definition at line 349 of file doublely_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. If the current pointer is at the head, the previous node is NULL.

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

Definition at line 370 of file doublely_linked_list.cpp.

int getSize ( DLinkedList dLinkedList )

getSize

Return the size of the doublely linked list

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

Definition at line 390 of file doublely_linked_list.cpp.

void* getTail ( DLinkedList dLinkedList )

getTail

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

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

Definition at line 317 of file doublely_linked_list.cpp.

int insertAfter ( DLinkedList dLinkedList,
void *  newData 
)

insertAfter

Insert a new node into the doublely linked list immediately after the current node. If the current node is NULL, this method fails. Do not update the current node.

Parameters:
dLinkedListA pointer to the doublely linked list.
newDataA void pointer to the new data to insert.
Returns:
1 if inserted the new data successfully 0 if the current pointer is NULL

Definition at line 86 of file doublely_linked_list.cpp.

int insertBefore ( DLinkedList dLinkedList,
void *  newData 
)

insertBefore

Insert a new node into the doublely linked list immediately before the current node. If the current node is NULL, this method fails. Do not update the current node.

Parameters:
dLinkedListA pointer to the doublely linked list
newDataA void pointer to the new data to insert
Returns:
1 if insert the new data successfully 0 if the current pointer is NULL

Definition at line 111 of file doublely_linked_list.cpp.

void insertHead ( DLinkedList dLinkedList,
void *  data 
)

InsertHead.

Insert the data to the head of the doublely linked list. Do not update the current node.

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

Definition at line 37 of file doublely_linked_list.cpp.

void insertTail ( DLinkedList dLinkedList,
void *  data 
)

insertTail

Insert the data to the tail of the doublely linked list. Do not update the current node.

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

Definition at line 62 of file doublely_linked_list.cpp.

void* removeBackward ( DLinkedList dLinkedList )

removeBackward

Remove the node the current pointer is pointed at from the list and return the data associated with the current node. Move the current pointer backward. Be aware that removeBackward will cause problems if the current node is the list head, or if the current node is the only node in the list. In these cases, the current pointer should be set to NULL after removing the node, and the list head and tail pointers should be updated appropriately.

Parameters:
dLinkedListA pointer to the doublely linked list
Returns:
the data of the removed node, or NULL if the current pointer is NULL

Definition at line 216 of file doublely_linked_list.cpp.

void* removeForward ( DLinkedList dLinkedList )

removeForward

Remove the node the current pointer is pointed at from the list and return the data associated with the current node. Move the current pointer forward. Be aware that removeForward will cause problems if the current node is the list tail, or if the current node is the only node in the list. In these cases, the current pointer should be set to NULL after removing the node, and the list head and tail pointers should be updated appropriately.

Parameters:
dLinkedListA pointer to the doublely linked list
Returns:
the data of the removed node, or NULL if the current pointer is NULL

Definition at line 250 of file doublely_linked_list.cpp.