diff options
author | Michael Schroeder <mls@suse.de> | 2007-10-29 15:00:30 +0000 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2007-10-29 15:00:30 +0000 |
commit | 2b4044a1591a6a97882ccb16c444148226cc7a7b (patch) | |
tree | fbf42a15d6e5f9be06e93035c60c9e1076225efc /src/queue.h | |
parent | 1a5e30f90920e0acabd3d0fb55770a86b30af0d6 (diff) | |
download | libsolv-2b4044a1591a6a97882ccb16c444148226cc7a7b.tar.gz libsolv-2b4044a1591a6a97882ccb16c444148226cc7a7b.tar.bz2 libsolv-2b4044a1591a6a97882ccb16c444148226cc7a7b.zip |
- rename queue* to queue_*, inline a bit more
- rename map* to map_*
Diffstat (limited to 'src/queue.h')
-rw-r--r-- | src/queue.h | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/queue.h b/src/queue.h index dd70443..9e9ee74 100644 --- a/src/queue.h +++ b/src/queue.h @@ -15,16 +15,54 @@ typedef struct _Queue { int left; // space left in alloc *after* elements+count } Queue; + +extern void queue_alloc_one(Queue *q); + // clear queue +static inline void +queue_empty(Queue *q) +{ + if (q->alloc) + { + q->left += (q->elements - q->alloc) + q->count; + q->elements = q->alloc; + } + else + q->left += q->count; + q->count = 0; +} + +static inline Id +queue_shift(Queue *q) +{ + if (!q->count) + return 0; + q->count--; + return *q->elements++; +} + +static inline void +queue_push(Queue *q, Id id) +{ + if (!q->left) + queue_alloc_one(q); + q->elements[q->count++] = id; + q->left--; +} -#define QUEUEEMPTY(q) ((q)->alloc ? ((q)->left += ((q)->elements - (q)->alloc) + (q)->count, (q)->elements = (q)->alloc, (q)->count = 0) : ((q)->left += (q)->count, (q)->count = 0)) +static inline void +queue_pushunique(Queue *q, Id id) +{ + int i; + for (i = q->count; i > 0; ) + if (q->elements[--i] == id) + return; + queue_push(q, id); +} -extern void clonequeue(Queue *t, Queue *s); -extern void queueinit(Queue *q); -extern void queueinit_buffer(Queue *q, Id *buf, int size); -extern void queuefree(Queue *q); -extern Id queueshift(Queue *q); -extern void queuepush(Queue *q, Id id); -extern void queuepushunique(Queue *q, Id id); +extern void queue_clone(Queue *t, Queue *s); +extern void queue_init(Queue *q); +extern void queue_init_buffer(Queue *q, Id *buf, int size); +extern void queue_free(Queue *q); #endif /* QUEUE_H */ |