2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
13 #ifndef SATSOLVER_QUEUE_H
14 #define SATSOLVER_QUEUE_H
16 #include "pooltypes.h"
18 typedef struct _Queue {
19 Id *elements; // current elements
20 int count; // current number of elements (minimal size for elements pointer)
21 Id *alloc; // this is whats actually allocated, elements > alloc if shifted
22 int left; // space left in alloc *after* elements+count
26 extern void queue_alloc_one(Queue *q);
34 q->left += (q->elements - q->alloc) + q->count;
35 q->elements = q->alloc;
48 return *q->elements++;
52 queue_push(Queue *q, Id id)
56 q->elements[q->count++] = id;
61 queue_pushunique(Queue *q, Id id)
64 for (i = q->count; i > 0; )
65 if (q->elements[--i] == id)
70 extern void queue_clone(Queue *t, Queue *s);
71 extern void queue_init(Queue *q);
72 extern void queue_init_buffer(Queue *q, Id *buf, int size);
73 extern void queue_free(Queue *q);
75 #endif /* SATSOLVER_QUEUE_H */