Go to the source code of this file.
|
typedef struct internal_deque * | queue |
|
◆ queue
typedef struct internal_deque* queue |
The queue data structure, which adapts a container to provide a queue (first-in first-out). Adapts the deque container.
◆ queue_back()
Gets the back element of the queue. The pointer to the data being obtained should point to the data type which this queue holds. For example, if this queue holds integers, the data pointer should be a pointer to an integer. Since this data is being copied from the array to the data pointer, the pointer only has to be valid when this function is called.
- Parameters
-
data | the copy of the back element of the queue |
me | the queue to copy from |
- Returns
- BK_TRUE if the queue contained elements, otherwise BK_FALSE
◆ queue_clear()
Clears the queue and sets it to the original state from initialization.
- Parameters
-
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ queue_copy_to_array()
void queue_copy_to_array |
( |
void *const |
arr, |
|
|
queue |
me |
|
) |
| |
Copies the queue to an array. Since it is a copy, the array may be modified without causing side effects to the queue data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called.
- Parameters
-
arr | the initialized array to copy the queue to |
me | the queue to copy to the array |
◆ queue_destroy()
Destroys the queue. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
- Parameters
-
- Returns
- NULL
◆ queue_front()
Gets the front element of the queue. The pointer to the data being obtained should point to the data type which this queue holds. For example, if this queue holds integers, the data pointer should be a pointer to an integer. Since this data is being copied from the array to the data pointer, the pointer only has to be valid when this function is called.
- Parameters
-
data | the copy of the front element of the queue |
me | the queue to copy from |
- Returns
- BK_TRUE if the queue contained elements, otherwise BK_FALSE
◆ queue_init()
queue queue_init |
( |
const size_t |
data_size | ) |
|
Initializes a queue.
- Parameters
-
data_size | the size of each element; must be positive |
- Returns
- the newly-initialized queue, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error
◆ queue_is_empty()
Determines if the queue is empty. The queue is empty if it contains no elements.
- Parameters
-
me | the queue to check if empty |
- Returns
- BK_TRUE if the queue is empty, otherwise BK_FALSE
◆ queue_pop()
Removes the next element in the queue and copies the data. The pointer to the data being obtained should point to the data type which this queue holds. For example, if this queue holds integers, the data pointer should be a pointer to an integer. Since this data is being copied from the array to the data pointer, the pointer only has to be valid when this function is called.
- Parameters
-
data | the data to have copied from the queue |
me | the queue to pop the next element from |
- Returns
- BK_TRUE if the queue contained elements, otherwise BK_FALSE
◆ queue_push()
Adds an element to the queue. The pointer to the data being passed in should point to the data type which this queue holds. For example, if this queue holds integers, the data pointer should be a pointer to an integer. Since the data is being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the queue to add an element to |
data | the data to add to the queue |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
-
-BK_ERANGE if size has reached representable limit
◆ queue_size()
size_t queue_size |
( |
queue |
me | ) |
|
Determines the size of the queue.
- Parameters
-
me | the queue to get size of |
- Returns
- the queue size
◆ queue_trim()
Frees the unused memory in the queue.
- Parameters
-
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory