29
29
typedef struct st_queue {
30
30
unsigned char **root;
31
31
void *first_cmp_arg;
34
uint offset_to_key; /* compare is done on element+offset */
33
uint32_t max_elements;
34
uint32_t offset_to_key; /* compare is done on element+offset */
35
35
int max_at_top; /* Normally 1, set to -1 if queue_top gives max */
36
36
int (*compare)(void *, unsigned char *,unsigned char *);
40
40
#define queue_top(queue) ((queue)->root[1])
46
46
(queue)->max_at_top= set_arg ? -1 : 1
47
47
typedef int (*queue_compare)(void *,unsigned char *, unsigned char *);
49
int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
49
int init_queue(QUEUE *queue,uint32_t max_elements,uint32_t offset_to_key,
50
50
bool max_at_top, queue_compare compare,
51
51
void *first_cmp_arg);
52
int init_queue_ex(QUEUE *queue,uint max_elements,uint offset_to_key,
52
int init_queue_ex(QUEUE *queue,uint32_t max_elements,uint32_t offset_to_key,
53
53
bool max_at_top, queue_compare compare,
54
void *first_cmp_arg, uint auto_extent);
55
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
54
void *first_cmp_arg, uint32_t auto_extent);
55
int reinit_queue(QUEUE *queue,uint32_t max_elements,uint32_t offset_to_key,
56
56
bool max_at_top, queue_compare compare,
57
57
void *first_cmp_arg);
58
int resize_queue(QUEUE *queue, uint max_elements);
58
int resize_queue(QUEUE *queue, uint32_t max_elements);
59
59
void delete_queue(QUEUE *queue);
60
60
void queue_insert(QUEUE *queue,unsigned char *element);
61
61
int queue_insert_safe(QUEUE *queue, unsigned char *element);
62
unsigned char *queue_remove(QUEUE *queue,uint idx);
62
unsigned char *queue_remove(QUEUE *queue,uint32_t idx);
63
63
#define queue_remove_all(queue) { (queue)->elements= 0; }
64
64
#define queue_is_full(queue) (queue->elements == queue->max_elements)
65
void _downheap(QUEUE *queue,uint idx);
65
void _downheap(QUEUE *queue,uint32_t idx);
66
66
void queue_fix(QUEUE *queue);
67
67
#define is_queue_inited(queue) ((queue)->root != 0)