11 typedef struct _Queue {
12 Id *elements; // current elements
13 int count; // current number of elements (minimal size for elements pointer)
14 Id *alloc; // this is whats actually allocated, elements > alloc if shifted
15 int left; // space left in alloc *after* elements+count
19 extern void queue_alloc_one(Queue *q);
27 q->left += (q->elements - q->alloc) + q->count;
28 q->elements = q->alloc;
41 return *q->elements++;
45 queue_push(Queue *q, Id id)
49 q->elements[q->count++] = id;
54 queue_pushunique(Queue *q, Id id)
57 for (i = q->count; i > 0; )
58 if (q->elements[--i] == id)
63 extern void queue_clone(Queue *t, Queue *s);
64 extern void queue_init(Queue *q);
65 extern void queue_init_buffer(Queue *q, Id *buf, int size);
66 extern void queue_free(Queue *q);