arrayqueue.h File Reference

This header file contains the structures and functions needed to work with queues (implemented using array lists). More...


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.


Detailed Description

This header file contains the structures and functions needed to work with queues (implemented using array lists).

Author:
Mihai Balan
It contains functions for creating a queue, destroying it and all the typical operations on a queue (enqueue, dequeue, front).

Typedef Documentation

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.

See also:
AQ_New(), AQ_Free(), AQ_Enqueue(), AQ_Dequeue(), AQ_Front().


Function Documentation

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.

Parameters:
queue the queue on which to perform the operation.
See also:
AQ_Front()

int AQ_Empty ( ArrayQueue  queue  ) 

Determines if the queue is empty or not.

The function actually returns the value of the expression Size==0/

Parameters:
queue queue to be tested
Returns:
-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.

Parameters:
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.

Parameters:
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.

Parameters:
queue the queue on which to perform the action.
Returns:
if queue is 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 ).

Returns:
pointer to the newly created stack.

int AQ_Size ( ArrayQueue  queue  ) 

Returns the size of the queue.

The function returns the number of elements in the queue.

Parameters:
queue queue to be tested.
Returns:
number of elements in the queue. -1 is returned if queue is NULL .


Generated on Sun Mar 18 17:24:46 2007 for Cobble by  doxygen 1.5.1