Main Page | Data Structures | File List | Data Fields | Globals

queue.h File Reference

Double-ended queue. More...


Typedefs

typedef _Queue Queue
 A double-ended queue.

Functions

Queuequeue_new (void)
 Create a new double-ended queue.
void queue_free (Queue *queue)
 Destroy a queue.
void queue_push_head (Queue *queue, void *data)
 Add data to the head of a queue.
void * queue_pop_head (Queue *queue)
 Remove data from the head of a queue.
void * queue_peek_head (Queue *queue)
 Read data from the head of queue, without removing it from the queue.
void queue_push_tail (Queue *queue, void *data)
 Add data to the tail of a queue.
void * queue_pop_tail (Queue *queue)
 Remove data from the tail of a queue.
void * queue_peek_tail (Queue *queue)
 Read data from the tail of queue, without removing it from the queue.
int queue_is_empty (Queue *queue)
 Query if any data is currently in a queue.


Detailed Description

Double-ended queue.

A double ended queue stores a list of pointers in order. New data can be added and removed from either end of the queue.

To create a new queue, use queue_new. To destroy a queue, use queue_free.

To add data to a queue, use queue_push_head and queue_push_tail.

To read data from the ends of a queue, use queue_pop_head and queue_pop_tail. To examine the ends without removing data from the queue, use queue_peek_head and queue_peek_tail.


Function Documentation

void queue_free Queue queue  ) 
 

Destroy a queue.

Parameters:
queue The queue to destroy.

int queue_is_empty Queue queue  ) 
 

Query if any data is currently in a queue.

Parameters:
queue The queue.
Returns:
Zero if the queue is not empty, non-zero if the queue is empty.

Queue* queue_new void   ) 
 

Create a new double-ended queue.

Returns:
A new queue.

void* queue_peek_head Queue queue  ) 
 

Read data from the head of queue, without removing it from the queue.

Parameters:
queue The queue.
Returns:
Data at the head of the queue, or NULL if the queue is empty.

void* queue_peek_tail Queue queue  ) 
 

Read data from the tail of queue, without removing it from the queue.

Parameters:
queue The queue.
Returns:
Data at the tail of the queue, or NULL if the queue is empty.

void* queue_pop_head Queue queue  ) 
 

Remove data from the head of a queue.

Parameters:
queue The queue.
Returns:
Data at the head of the queue, or NULL if the queue is empty.

void* queue_pop_tail Queue queue  ) 
 

Remove data from the tail of a queue.

Parameters:
queue The queue.
Returns:
Data at the head of the queue, or NULL if the queue is empty.

void queue_push_head Queue queue,
void *  data
 

Add data to the head of a queue.

Parameters:
queue The queue.
data The data to add.

void queue_push_tail Queue queue,
void *  data
 

Add data to the tail of a queue.

Parameters:
queue The queue.
data The data to add.


Generated on Mon Jan 30 18:56:23 2006 for C Algorithms by  doxygen 1.4.4