tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
queue.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * queue.h
4  *
5  * =============================================================================
6  *
7  * Copyright (C) Stanford University, 2006. All Rights Reserved.
8  * Author: Chi Cao Minh
9  *
10  * =============================================================================
11  *
12  * For the license of bayes/sort.h and bayes/sort.c, please see the header
13  * of the files.
14  *
15  * ------------------------------------------------------------------------
16  *
17  * For the license of kmeans, please see kmeans/LICENSE.kmeans
18  *
19  * ------------------------------------------------------------------------
20  *
21  * For the license of ssca2, please see ssca2/COPYRIGHT
22  *
23  * ------------------------------------------------------------------------
24  *
25  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
26  * header of the files.
27  *
28  * ------------------------------------------------------------------------
29  *
30  * For the license of lib/rbtree.h and lib/rbtree.c, please see
31  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
32  *
33  * ------------------------------------------------------------------------
34  *
35  * Unless otherwise noted, the following license applies to STAMP files:
36  *
37  * Copyright (c) 2007, Stanford University
38  * All rights reserved.
39  *
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions are
42  * met:
43  *
44  * * Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  *
47  * * Redistributions in binary form must reproduce the above copyright
48  * notice, this list of conditions and the following disclaimer in
49  * the documentation and/or other materials provided with the
50  * distribution.
51  *
52  * * Neither the name of Stanford University nor the names of its
53  * contributors may be used to endorse or promote products derived
54  * from this software without specific prior written permission.
55  *
56  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
57  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
60  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
66  * THE POSSIBILITY OF SUCH DAMAGE.
67  *
68  * =============================================================================
69  */
70 
71 
72 #ifndef QUEUE_H
73 #define QUEUE_H 1
74 
75 
76 #include "random.h"
77 #include "tm.h"
78 #include "types.h"
79 
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 
86 typedef struct queue queue_t;
87 
88 
89 /* =============================================================================
90  * queue_alloc
91  * =============================================================================
92  */
93 queue_t*
94 queue_alloc (long initCapacity);
95 
96 
97 /* =============================================================================
98  * Pqueue_alloc
99  * =============================================================================
100  */
101 queue_t*
102 Pqueue_alloc (long initCapacity);
103 
104 
105 /* =============================================================================
106  * TMqueue_alloc
107  * =============================================================================
108  */
109 queue_t*
110 TMqueue_alloc (TM_ARGDECL long initCapacity);
111 
112 
113 /* =============================================================================
114  * queue_free
115  * =============================================================================
116  */
117 void
118 queue_free (queue_t* queuePtr);
119 
120 
121 /* =============================================================================
122  * Pqueue_free
123  * =============================================================================
124  */
125 void
126 Pqueue_free (queue_t* queuePtr);
127 
128 
129 /* =============================================================================
130  * TMqueue_free
131  * =============================================================================
132  */
133 void
134 TMqueue_free (TM_ARGDECL queue_t* queuePtr);
135 
136 
137 /* =============================================================================
138  * queue_isEmpty
139  * =============================================================================
140  */
141 bool_t
142 queue_isEmpty (queue_t* queuePtr);
143 
144 
145 /* =============================================================================
146  * TMqueue_isEmpty
147  * =============================================================================
148  */
150 bool_t
152 
153 
154 /* =============================================================================
155  * queue_clear
156  * =============================================================================
157  */
158 void
159 queue_clear (queue_t* queuePtr);
160 void
161 TMqueue_clear (TM_ARGDECL queue_t* queuePtr);
162 
163 
164 /* =============================================================================
165  * queue_shuffle
166  * =============================================================================
167  */
168 void
169 queue_shuffle (queue_t* queuePtr, random_t* randomPtr);
170 
171 
172 /* =============================================================================
173  * queue_push
174  * =============================================================================
175  */
176 bool_t
177 queue_push (queue_t* queuePtr, void* dataPtr);
178 
179 
180 /* =============================================================================
181  * Pqueue_push
182  * =============================================================================
183  */
184 bool_t
185 Pqueue_push (queue_t* queuePtr, void* dataPtr);
186 
187 
188 /* =============================================================================
189  * TMqueue_push
190  * =============================================================================
191  */
193 bool_t
194 TMqueue_push (TM_ARGDECL queue_t* queuePtr, void* dataPtr);
195 
196 
197 /* =============================================================================
198  * queue_pop
199  * =============================================================================
200  */
201 void*
202 queue_pop (queue_t* queuePtr);
203 
204 
205 /* =============================================================================
206  * TMqueue_pop
207  * =============================================================================
208  */
210 void*
211 TMqueue_pop (TM_ARGDECL queue_t* queuePtr);
212 
213 
214 #define PQUEUE_ALLOC(c) Pqueue_alloc(c)
215 #define PQUEUE_FREE(q) Pqueue_free(q)
216 #define PQUEUE_ISEMPTY(q) queue_isEmpty(q)
217 #define PQUEUE_CLEAR(q) queue_clear(q)
218 #define PQUEUE_SHUFFLE(q) queue_shuffle(q, randomPtr);
219 #define PQUEUE_PUSH(q, d) Pqueue_push(q, (void*)(d))
220 #define PQUEUE_POP(q) queue_pop(q)
221 
222 #define TMQUEUE_ALLOC(c) TMqueue_alloc(TM_ARG c)
223 #define TMQUEUE_FREE(q) TMqueue_free(TM_ARG q)
224 #define TMQUEUE_ISEMPTY(q) TMqueue_isEmpty(TM_ARG q)
225 #define TMQUEUE_PUSH(q, d) TMqueue_push(TM_ARG q, (void*)(d))
226 #define TMQUEUE_POP(q) TMqueue_pop(TM_ARG q)
227 #define TMQUEUE_CLEAR(q) TMqueue_clear(TM_ARG q)
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 
234 #endif /* QUEUE_H */
235 
236 
237 /* =============================================================================
238  *
239  * End of queue.h
240  *
241  * =============================================================================
242  */
243 
queue_t * queue_alloc(long initCapacity)
Definition: queue.c:98
#define TM_CALLABLE
Definition: cxxtm.hpp:32
queue_t * TMqueue_alloc(TM_ARGDECL long initCapacity)
Definition: queue.c:148
bool_t queue_push(queue_t *queuePtr, void *dataPtr)
Definition: queue.c:291
void Pqueue_free(queue_t *queuePtr)
Definition: queue.c:185
void queue_shuffle(queue_t *queuePtr, random_t *randomPtr)
Definition: queue.c:258
TM_CALLABLE bool_t TMqueue_isEmpty(TM_ARGDECL queue_t *queuePtr)
Definition: queue.c:243
void queue_free(queue_t *queuePtr)
Definition: queue.c:173
Definition: queue.c:81
void queue_clear(queue_t *queuePtr)
Definition: queue.c:224
int bool_t
Definition: portable_defns.h:32
TM_CALLABLE void * TMqueue_pop(TM_ARGDECL queue_t *queuePtr)
Definition: queue.c:481
#define TM_ARGDECL
Definition: tm.h:532
void TMqueue_free(TM_ARGDECL queue_t *queuePtr)
Definition: queue.c:197
void * queue_pop(queue_t *queuePtr)
Definition: queue.c:458
TM_CALLABLE bool_t TMqueue_push(TM_ARGDECL queue_t *queuePtr, void *dataPtr)
Definition: queue.c:402
bool_t Pqueue_push(queue_t *queuePtr, void *dataPtr)
Definition: queue.c:346
void TMqueue_clear(TM_ARGDECL queue_t *queuePtr)
Definition: queue.c:231
bool_t queue_isEmpty(queue_t *queuePtr)
Definition: queue.c:209
Definition: random.h:86
queue_t * Pqueue_alloc(long initCapacity)
Definition: queue.c:123