Typedefs | |
| typedef arrayqueue_adt * | ArrayQueue |
| Pointer to structure representing a queue. | |
Functions | |
| ArrayQueue | AQ_New () |
| Creates a new queue. | |
| void | AQ_Free (ArrayQueue queue) |
| Destroys the specified queue. | |
| int | AQ_Size (ArrayQueue queue) |
| Returns the size of the queue. | |
| int | AQ_Empty (ArrayQueue queue) |
| Determines if the queue is empty or not. | |
| void | AQ_Enqueue (ArrayQueue queue, void *el) |
| Adds an element at the back of the queue. | |
| void | AQ_Dequeue (ArrayQueue queue) |
| Removes an element from the front of the queue. | |
| void * | AQ_Front (ArrayQueue queue) |
| Retrieves the data in the element at the front of the queue. | |
It contains functions for creating a queue, destroying it and all the typical operations on a queue (enqueue, dequeue, front).
| typedef struct arrayqueue_adt* ArrayQueue |
Pointer to structure representing a queue.
The ArrayQueue is implemented using a ArrayList . However, the underlying ArrayList should not be modified directly but only through the appropriate functions.
As is the case with the ArrayList , element data is stored using a void* pointer. Thus, one should note that there is no way to tell what kind of data is stored inthe list or in a particular element.
| void AQ_Dequeue | ( | ArrayQueue | queue | ) |
Removes an element from the front of the queue.
The function removes the element at the front of the queue. Note that the data in that element is not freed so that it can be further referenced.
| queue | the queue on which to perform the operation. |
| int AQ_Empty | ( | ArrayQueue | queue | ) |
Determines if the queue is empty or not.
The function actually returns the value of the expression Size==0/
| queue | queue to be tested |
-1 if queue is NULL, 1 if the queue is empty, 0 otherwise. | void AQ_Enqueue | ( | ArrayQueue | queue, | |
| void * | el | |||
| ) |
Adds an element at the back of the queue.
The function adds the data specified by el at the end of the queue.
| queue | the queue to add data to. | |
| *el | pointer to an initialied memory location containing the data to be added to the back of the queue. |
| void AQ_Free | ( | ArrayQueue | queue | ) |
Destroys the specified queue.
The function frees the memory used by the structure itself as well as the memory used by the data in the queue, so trying to access the data after the destruction of the queue (e.g. through a pointer) will most likely resutl in a Access Violation / segfault.
| queue | ArrayQueue representing the queue to be destroyed. |
| void* AQ_Front | ( | ArrayQueue | queue | ) |
Retrieves the data in the element at the front of the queue.
The function returns the data in the element at the front of the queue but does not alter in any way the structure of the queue. However the actual data can be changed through the use of the void* pointer returned, which points to the memory location containing the data.
| queue | the queue on which to perform the action. |
NULL or empty, it returns NULL . Otherwise, it returns a pointer to the memory location where the data in the element at the front of the queue is stored. | ArrayQueue AQ_New | ( | ) |
Creates a new queue.
The function creates a new array queue (queue implemented using an ArayList ).
| int AQ_Size | ( | ArrayQueue | queue | ) |
Returns the size of the queue.
The function returns the number of elements in the queue.
| queue | queue to be tested. |
-1 is returned if queue is NULL .
1.5.1