blob: f62c94102d962c79f56042679ca1a22e385e1adb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "Core.h"
#ifndef CC_QUEUE_H
#define CC_QUEUE_H
struct Queue {
cc_uint8* entries; /* Buffer holding the bytes of the queue */
int structSize; /* Size in bytes of the type of structure this queue holds */
int capacity; /* Max number of elements in the buffer */
int mask; /* capacity - 1, as capacity is always a power of two */
int count; /* Number of used elements */
int head; /* Head index into the buffer */
int tail; /* Tail index into the buffer */
};
void Queue_Init(struct Queue* queue, cc_uint32 structSize);
/* Appends an entry to the end of the queue, resizing if necessary. */
void Queue_Enqueue(struct Queue* queue, void* item);
/* Retrieves the entry from the front of the queue. */
void* Queue_Dequeue(struct Queue* queue);
/* Frees the memory of the queue and resets the members to 0. */
void Queue_Clear(struct Queue* queue);
#endif
|