ATLAS Offline Software
Macros | Typedefs | Functions
queue.h File Reference

Double-ended queue. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define QUEUE_NULL   ((void *) 0)
 A null QueueValue. More...
 

Typedefs

typedef struct _Queue Queue
 A double-ended queue. More...
 
typedef void * QueueValue
 A value stored in a Queue. More...
 

Functions

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

Detailed Description

Double-ended queue.

A double ended queue stores a list of values in order. New values 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 values to a queue, use queue_push_head and queue_push_tail.

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

Definition in file queue.h.

Macro Definition Documentation

◆ QUEUE_NULL

#define QUEUE_NULL   ((void *) 0)

A null QueueValue.

Definition at line 65 of file queue.h.

Typedef Documentation

◆ Queue

typedef struct _Queue Queue

A double-ended queue.

Definition at line 1 of file queue.h.

◆ QueueValue

typedef void* QueueValue

A value stored in a Queue.

Definition at line 58 of file queue.h.

Function Documentation

◆ queue_free()

void queue_free ( Queue queue)

Destroy a queue.

Parameters
queueThe queue to destroy.

◆ queue_is_empty()

int queue_is_empty ( Queue queue)

Query if any values are currently in a queue.

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

◆ queue_new()

Queue* queue_new ( void  )

Create a new double-ended queue.

Returns
A new queue, or NULL if it was not possible to allocate the memory.

◆ queue_peek_head()

QueueValue queue_peek_head ( Queue queue)

Read value from the head of a queue, without removing it from the queue.

Parameters
queueThe queue.
Returns
Value at the head of the queue, or QUEUE_NULL if the queue is empty.

◆ queue_peek_tail()

QueueValue queue_peek_tail ( Queue queue)

Read a value from the tail of a queue, without removing it from the queue.

Parameters
queueThe queue.
Returns
Value at the tail of the queue, or QUEUE_NULL if the queue is empty.

◆ queue_pop_head()

QueueValue queue_pop_head ( Queue queue)

Remove a value from the head of a queue.

Parameters
queueThe queue.
Returns
Value that was at the head of the queue, or QUEUE_NULL if the queue is empty.

◆ queue_pop_tail()

QueueValue queue_pop_tail ( Queue queue)

Remove a value from the tail of a queue.

Parameters
queueThe queue.
Returns
Value that was at the head of the queue, or QUEUE_NULL if the queue is empty.

◆ queue_push_head()

int queue_push_head ( Queue queue,
QueueValue  data 
)

Add a value to the head of a queue.

Parameters
queueThe queue.
dataThe value to add.
Returns
Non-zero if the value was added successfully, or zero if it was not possible to allocate the memory for the new entry.

◆ queue_push_tail()

int queue_push_tail ( Queue queue,
QueueValue  data 
)

Add a value to the tail of a queue.

Parameters
queueThe queue.
dataThe value to add.
Returns
Non-zero if the value was added successfully, or zero if it was not possible to allocate the memory for the new entry.