Statistics
| Branch: | Revision:

grapes / src / Utils / fifo_queue.h @ f83be11a

History | View | Annotate | Download (976 Bytes)

1
#ifndef FIFO_QUEUE
2
#define FIFO_QUEUE
3

    
4

    
5
typedef struct fifo_queue *fifo_queue_p;
6

    
7
/* Creates a fifo queue with the specified initial size */
8
fifo_queue_p fifo_queue_create(int size);
9

    
10
/* Destroy the fifo queue using free_ptr to deallocate elements. If
11
   free_ptr is NULL the standard free will be used */
12
void fifo_queue_destroy(fifo_queue_p queue, void (*free_ptr)(void *ptr));
13

    
14
/* Return the current actual size of the queue (nr of elements contained) */
15
int fifo_queue_size(fifo_queue_p queue);
16

    
17
/* Add the specified element to the tail of the queue. Return 1 on
18
   succes, 0 on error */
19
int fifo_queue_add(fifo_queue_p queue, void *element);
20

    
21
/* Return the head of the queue or NULL on error */
22
void* fifo_queue_get_head(fifo_queue_p queue);
23

    
24
/* Return the element at position nr or NULL on error */
25
void* fifo_queue_get(fifo_queue_p queue, int nr);
26

    
27
/* Remove and return the head of the queue of NULL on error */
28
void* fifo_queue_remove_head(fifo_queue_p queue);
29
#endif