First in, first out.
More...
Go to the source code of this file.
|
typedef struct fifo_queue | Queue |
First in, first out.
Method | Time complexity |
init | O(1) |
destroy | O(n) |
clear | O(n) |
enqueue | O(1) |
dequeue | O(1) |
get | O(n) |
get_head | O(1) |
get_tail | O(1) |
get_size | O(n) |
is_empty | O(1) |
◆ Queue
typedef struct fifo_queue Queue |
◆ queue_clear()
void queue_clear |
( |
Queue * | | ) |
|
Truncates the queue to length = 0.
◆ queue_dequeue()
int queue_dequeue |
( |
Queue * | , |
|
|
void * | data_cont ) |
Removes an element from the front of the Queue.
The removed element is copied to data_cont.
- Parameters
-
data_cont | pointer to space in memory able to hold at least Queue::el_size bytes or NULL |
- Returns
- RV_EXCEPTION if queue is empty, else RV_SUCCESS
◆ queue_destroy()
void queue_destroy |
( |
Queue * | | ) |
|
Frees all memory owned by the queue.
◆ queue_enqueue()
int queue_enqueue |
( |
Queue * | , |
|
|
const void * | data ) |
Appends an element to the end of the Queue.
- Parameters
-
- Returns
- RV_ERROR if alloc fails, else RV_SUCCESS
◆ queue_get()
int queue_get |
( |
const Queue * | , |
|
|
size_t | index, |
|
|
void * | data_cont ) |
Fetches an item at index.
- Parameters
-
index | |
data_cont | pointer to space in memory able to hold at least Queue::el_size bytes |
- Returns
- RV_EXCEPTION if either
- index is OOB
- data_cont is NULL
◆ queue_get_head()
int queue_get_head |
( |
const Queue * | , |
|
|
void * | data_cont ) |
Fetches the next item to be dequeued.
- Parameters
-
data_cont | pointer to space in memory able to hold at least Queue::el_size bytes |
- Returns
- RV_EXCEPTION if no head
◆ queue_get_size()
size_t queue_get_size |
( |
const Queue * | | ) |
|
Length of queue (number of items)
◆ queue_get_tail()
int queue_get_tail |
( |
const Queue * | , |
|
|
void * | data_cont ) |
Fetches the last item that was enqueued.
- Parameters
-
data_cont | pointer to space in memory able to hold at least Queue::el_size bytes |
- Returns
- RV_EXCEPTION if there are no items
◆ queue_init()
Initializes a FIFO queue.
- Parameters
-
el_size | sizeof a single element |
- Returns
- pointer to a valid Queue or NULL
◆ queue_is_empty()
bool queue_is_empty |
( |
const Queue * | | ) |
|
◆ queue_node_get_data()
const void * queue_node_get_data |
( |
const struct queue_node * | | ) |
|
- Returns
- queue node data pointer