Mercury
mercury_queue.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2005-2008, Simon Howard
4 
5 Permission to use, copy, modify, and/or distribute this software
6 for any purpose with or without fee is hereby granted, provided
7 that the above copyright notice and this permission notice appear
8 in all copies.
9 
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 
19  */
20 
41 #ifndef MERCURY_QUEUE_H
42 #define MERCURY_QUEUE_H
43 
44 #include "mercury_util_config.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
54 typedef struct hg_queue hg_queue_t;
55 
60 typedef void * hg_queue_value_t;
61 
66 #define HG_QUEUE_NULL ((void *) 0)
67 
74 HG_UTIL_EXPORT hg_queue_t *
75 hg_queue_new(void);
76 
83 HG_UTIL_EXPORT void
85 
95 HG_UTIL_EXPORT int
96 hg_queue_push_head(hg_queue_t *queue, hg_queue_value_t data);
97 
105 HG_UTIL_EXPORT hg_queue_value_t
107 
116 HG_UTIL_EXPORT hg_queue_value_t
118 
128 HG_UTIL_EXPORT int
129 hg_queue_push_tail(hg_queue_t *queue, hg_queue_value_t data);
130 
138 HG_UTIL_EXPORT hg_queue_value_t
140 
149 HG_UTIL_EXPORT hg_queue_value_t
151 
159 HG_UTIL_EXPORT int
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* MERCURY_QUEUE_H */
167 
void * hg_queue_value_t
A value stored in a hg_queue_t.
Definition: mercury_queue.h:60
HG_UTIL_EXPORT hg_queue_value_t hg_queue_pop_head(hg_queue_t *queue)
Remove a value from the head of a queue.
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.
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.
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.
HG_UTIL_EXPORT hg_queue_value_t hg_queue_pop_tail(hg_queue_t *queue)
Remove a value from the tail of a queue.
HG_UTIL_EXPORT hg_queue_t * hg_queue_new(void)
Create a new double-ended queue.
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.
struct hg_queue hg_queue_t
A double-ended queue.
Definition: mercury_queue.h:54
HG_UTIL_EXPORT int hg_queue_is_empty(hg_queue_t *queue)
Query if any values are currently in a queue.
HG_UTIL_EXPORT void hg_queue_free(hg_queue_t *queue)
Destroy a queue.