diff options
author | WlodekM <[email protected]> | 2024-06-16 10:35:45 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-06-16 10:35:45 +0300 |
commit | abef6da56913f1c55528103e60a50451a39628b1 (patch) | |
tree | b3c8092471ecbb73e568cd0d336efa0e7871ee8d /src/Queue.h |
initial commit
Diffstat (limited to 'src/Queue.h')
-rw-r--r-- | src/Queue.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Queue.h b/src/Queue.h new file mode 100644 index 0000000..f62c941 --- /dev/null +++ b/src/Queue.h @@ -0,0 +1,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 \ No newline at end of file |