Kohi Game Engine
queue.h File Reference

A simple queue container. Elements are popped off the queue in the same order they were pushed to it. More...

#include "defines.h"

Go to the source code of this file.

Data Structures

struct  queue
 A simple queue container. Elements are popped off the queue in the same order they were pushed to it. More...
 

Typedefs

typedef struct queue queue
 A simple queue container. Elements are popped off the queue in the same order they were pushed to it. More...
 

Functions

KAPI b8 queue_create (queue *out_queue, u32 element_size)
 Creates a new queue. More...
 
KAPI void queue_destroy (queue *s)
 Destroys the given queue. More...
 
KAPI b8 queue_push (queue *s, void *element_data)
 Pushes an element (a copy of the element data) into the back of the queue. More...
 
KAPI b8 queue_peek (const queue *s, void *out_element_data)
 Attempts to peek an element (writing out a copy of the element data on success) from the queue. If the queue is empty, nothing is done and false is returned. The queue memory is not modified. More...
 
KAPI b8 queue_pop (queue *s, void *out_element_data)
 Attempts to pop an element (writing out a copy of the element data on success) from the front of the queue. If the queue is empty, nothing is done and false is returned. More...
 

Detailed Description

A simple queue container. Elements are popped off the queue in the same order they were pushed to it.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2024-02-04

Typedef Documentation

◆ queue

typedef struct queue queue

A simple queue container. Elements are popped off the queue in the same order they were pushed to it.

Function Documentation

◆ queue_create()

KAPI b8 queue_create ( queue out_queue,
u32  element_size 
)

Creates a new queue.

Parameters
out_queueA pointer to hold the newly-created queue.
element_sizeThe size of each element in the queue.
Returns
True on success; otherwise false.

◆ queue_destroy()

KAPI void queue_destroy ( queue s)

Destroys the given queue.

Parameters
sA pointer to the queue to be destroyed.

◆ queue_peek()

KAPI b8 queue_peek ( const queue s,
void *  out_element_data 
)

Attempts to peek an element (writing out a copy of the element data on success) from the queue. If the queue is empty, nothing is done and false is returned. The queue memory is not modified.

Parameters
sA pointer to the queue to peek from.
element_dataA pointer to write the element data to. Required.
Returns
True on succcess; otherwise false.

◆ queue_pop()

KAPI b8 queue_pop ( queue s,
void *  out_element_data 
)

Attempts to pop an element (writing out a copy of the element data on success) from the front of the queue. If the queue is empty, nothing is done and false is returned.

Parameters
sA pointer to the queue to pop from.
element_dataA pointer to write the element data to. Required.
Returns
True on succcess; otherwise false.

◆ queue_push()

KAPI b8 queue_push ( queue s,
void *  element_data 
)

Pushes an element (a copy of the element data) into the back of the queue.

Parameters
sA pointer to the queue to push to.
element_dataThe element data to be pushed. Required.
Returns
True on succcess; otherwise false.