-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.h
44 lines (32 loc) · 779 Bytes
/
queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# ifndef _QUEUE_H
# define _QUEUE_H
# include <stdint.h>
# include <stdbool.h>
# include "huffman.h"
# ifndef NIL
# define NIL (void *) 0
# endif
# ifndef ROOT
# define ROOT 1
# endif
# ifndef VALNODE
# define VALNODE(q, n) ((q)->nodes[n].count)
# endif
typedef treeNode queueItem;
typedef struct queue
{
uint32_t size; // How big is it? (number of entries)
uint32_t head; // Where is the next element?
queueItem *nodes; // Array of nodes for the heap
} queue;
queue *newQueue(uint32_t size);
void delQueue(queue *q);
// Adds an item to the queue
bool enqueue(queue *q, queueItem i);
// Removes the smallest item from the queue
bool dequeue(queue *q, queueItem *i);
// Is it full?
bool fullQueue(queue *q);
// Is it empty?
bool emptyQueue(queue *q);
# endif