Mercury
Macros | Typedefs | Functions
mercury_queue.h File Reference
#include "mercury_util_config.h"
Include dependency graph for mercury_queue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HG_QUEUE_NULL   ((void *) 0)
 A null hg_queue_value_t. More...
 

Typedefs

typedef struct hg_queue hg_queue_t
 A double-ended queue. More...
 
typedef void * hg_queue_value_t
 A value stored in a hg_queue_t. More...
 

Functions

HG_UTIL_EXPORT hg_queue_thg_queue_new (void)
 Create a new double-ended queue. More...
 
HG_UTIL_EXPORT void hg_queue_free (hg_queue_t *queue)
 Destroy a queue. More...
 
HG_UTIL_EXPORT int hg_queue_push_head (hg_queue_t *queue, hg_queue_value_t data)
 Add a value to the head of a queue. More...
 
HG_UTIL_EXPORT hg_queue_value_t hg_queue_pop_head (hg_queue_t *queue)
 Remove a value from the head of a queue. More...
 
HG_UTIL_EXPORT hg_queue_value_t hg_queue_peek_head (hg_queue_t *queue)
 Read value from the head of a queue, without removing it from the queue. More...
 
HG_UTIL_EXPORT int hg_queue_push_tail (hg_queue_t *queue, hg_queue_value_t data)
 Add a value to the tail of a queue. More...
 
HG_UTIL_EXPORT hg_queue_value_t hg_queue_pop_tail (hg_queue_t *queue)
 Remove a value from the tail of a queue. More...
 
HG_UTIL_EXPORT hg_queue_value_t hg_queue_peek_tail (hg_queue_t *queue)
 Read a value from the tail of a queue, without removing it from the queue. More...
 
HG_UTIL_EXPORT int hg_queue_is_empty (hg_queue_t *queue)
 Query if any values are currently in a queue. More...
 

Macro Definition Documentation

#define HG_QUEUE_NULL   ((void *) 0)

A null hg_queue_value_t.

Definition at line 66 of file mercury_queue.h.

Typedef Documentation

typedef struct hg_queue hg_queue_t

A double-ended queue.

Definition at line 54 of file mercury_queue.h.

typedef void* hg_queue_value_t

A value stored in a hg_queue_t.

Definition at line 60 of file mercury_queue.h.

Function Documentation

HG_UTIL_EXPORT hg_queue_t* hg_queue_new ( void  )

Create a new double-ended queue.

Returns
A new queue, or NULL if it was not possible to allocate the memory.
HG_UTIL_EXPORT void hg_queue_free ( hg_queue_t queue)

Destroy a queue.

User is responsible for freeing allocated data that was pushed to the queue.

Parameters
queueThe queue to destroy.
HG_UTIL_EXPORT int hg_queue_push_head ( hg_queue_t queue,
hg_queue_value_t  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.
HG_UTIL_EXPORT hg_queue_value_t hg_queue_pop_head ( hg_queue_t 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.
HG_UTIL_EXPORT hg_queue_value_t hg_queue_peek_head ( hg_queue_t 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.
HG_UTIL_EXPORT int hg_queue_push_tail ( hg_queue_t queue,
hg_queue_value_t  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.
HG_UTIL_EXPORT hg_queue_value_t hg_queue_pop_tail ( hg_queue_t 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.
HG_UTIL_EXPORT hg_queue_value_t hg_queue_peek_tail ( hg_queue_t 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.
HG_UTIL_EXPORT int hg_queue_is_empty ( hg_queue_t 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.