|
Veritable Lasagna
An Allocator & Data Structure Library for C.
|
#include "vl_linear_pool.h"
Include dependency graph for vl_queue.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | vl_queue |
| First in, first out queue. More... | |
Functions | |
| void | vlQueueInit (vl_queue *queue, vl_memsize_t elementSize) |
| Initializes the specified queue. | |
| void | vlQueueFree (vl_queue *queue) |
| Frees the specified queue. | |
| vl_queue * | vlQueueNew (vl_memsize_t elementSize) |
| Allocates on the heap, initializes, and returns a queue instance. | |
| void | vlQueueDelete (vl_queue *queue) |
| Deletes the specified queue. | |
| vl_queue * | vlQueueClone (const vl_queue *src, vl_queue *dest) |
| Clones the specified queue to another. | |
| void | vlQueueReserve (vl_queue *queue, vl_memsize_t n) |
| Reserves space for n-many elements in the underlying buffer of the specified queue. | |
| void | vlQueueClear (vl_queue *queue) |
| Clears the specified queue. | |
| void | vlQueuePushBack (vl_queue *queue, const void *element) |
| Adds a new element to the end of the queue. | |
| int | vlQueuePopFront (vl_queue *queue, void *element) |
| Copies the first element in the queue, and removes it from the queue. | |
| vl_dsidx_t | vlQueueSize (vl_queue *queue) |
| Returns the total number of elements in the specified queue. | |
| struct vl_queue |
First in, first out queue.
The Queue data structure is a simplified forward-facing linked list. It is implemented on top of a pool allocator, and thus requires all elements in the queue to be the same size.
Items may be added to the end and removed from the beginning. Just like the vl_deque data structure, direct sampling is also disallowed. Thus, all IO requires a copy.
Collaboration diagram for vl_queue:| Data Fields | ||
|---|---|---|
| vl_memsize_t | elementSize | |
| vl_linearpool_idx | head | |
| vl_linearpool | nodes | |
| vl_linearpool_idx | tail | |
| void vlQueueClear | ( | vl_queue * | queue | ) |
Clears the specified queue.
The underlying data in the queue is untouched, but rather some book-keeping variables are reset.
| queue |
Here is the call graph for this function:Clones the specified queue to another.
Clones the entirety of the src queue to the dest queue.
The 'src' queue pointer must be non-null and initialized. The 'dest' queue pointer may be null, but if it is not null it must be initialized.
If the 'dest' queue pointer is null, a new queue is created via vlQueueNew. Otherwise, its element size is set to the source's and all of its existing data is replaced.
| src | pointer |
| dest | pointer |
Here is the call graph for this function:| void vlQueueDelete | ( | vl_queue * | queue | ) |
Deletes the specified queue.
The queue should have been initialized via vlQueueNew.
| queue | pointer |
Here is the call graph for this function:| void vlQueueFree | ( | vl_queue * | queue | ) |
Frees the specified queue.
The queue should have been initialized via vlQueueInit.
| queue | pointer |
Here is the call graph for this function:
Here is the caller graph for this function:| void vlQueueInit | ( | vl_queue * | queue, |
| vl_memsize_t | elementSize ) |
Initializes the specified queue.
The queue should then later be freed via vlQueueFree.
| queue | pointer |
| elementSize | size of a single queue element, in bytes |
Here is the call graph for this function:
Here is the caller graph for this function:| vl_queue * vlQueueNew | ( | vl_memsize_t | elementSize | ) |
Allocates on the heap, initializes, and returns a queue instance.
The queue should then later be deleted via vlQueueDelete.
| elementSize | size of a single queue element, in bytes |
Here is the call graph for this function:
Here is the caller graph for this function:| int vlQueuePopFront | ( | vl_queue * | queue, |
| void * | element ) |
Copies the first element in the queue, and removes it from the queue.
This is a no-op if the queue is empty.
| queue | pointer |
| element | data pointer |
Here is the call graph for this function:| void vlQueuePushBack | ( | vl_queue * | queue, |
| const void * | element ) |
Adds a new element to the end of the queue.
The element data is copied to the queue.
| queue | pointer |
| element | data pointer |
Here is the call graph for this function:| void vlQueueReserve | ( | vl_queue * | queue, |
| vl_memsize_t | n ) |
Reserves space for n-many elements in the underlying buffer of the specified queue.
This is done by doubling the size until the requested growth is met or exceeded. This function will always result in the reallocation of the underlying memory.
| queue | pointer |
| n | total number of elements to reserve space for. |
Here is the call graph for this function:| vl_dsidx_t vlQueueSize | ( | vl_queue * | queue | ) |
Returns the total number of elements in the specified queue.
| queue | pointer |