#include <stdlib.h>
#include "tkqueue.h"
Go to the source code of this file.
◆ _queue_ensure_size()
Definition at line 58 of file tkqueue.c.
59{
61 return;
62 }
63
66}
token_t ** data
Pointer to queue data with allocated space to fit _size items.
unsigned int length
The current number of items on the queue.
unsigned int _size
Current number of elements that fits on the queue.
#define QUEUE_LENGTH_INCREMENT
struct token token_t
Struct for a Mya token.
◆ tkqueue_add()
Add a value to the token queue.
- Parameters
-
queue | The queue where to add the item. |
item | The value to add. |
Definition at line 25 of file tkqueue.c.
26{
29}
void _queue_ensure_size(tkqueue_t *queue)
◆ tkqueue_close()
Close the given queue.
- Parameters
-
Definition at line 18 of file tkqueue.c.
◆ tkqueue_get()
Get the current value from the queue and increment the position for the next value.
- Parameters
-
queue | The queue where to get the value. |
- Returns
- NULL when the queue is empty.
-
Pointer to the item.
Definition at line 32 of file tkqueue.c.
33{
35 return NULL;
36 }
37
39}
int _current
The index for the current item.
int tkqueue_isempty(const tkqueue_t *queue)
Check if the given queue is empty.
◆ tkqueue_init()
void tkqueue_init |
( |
tkqueue_t * | queue, |
|
|
unsigned int | initial_size ) |
Initializes the token queue.
- Parameters
-
queue | The queue to be initialized. |
initial_size | The initial number of items that fit the queue's memory data. |
Definition at line 9 of file tkqueue.c.
10{
13 queue->
_size = initial_size;
14 queue->
data = malloc(
sizeof(
token_t*) * initial_size);
15}
◆ tkqueue_isempty()
int tkqueue_isempty |
( |
const tkqueue_t * | queue | ) |
|
Check if the given queue is empty.
- Parameters
-
queue | The queue to check if it's empty. |
- Returns
- 1 on the queue is empty.
-
0 on the queue has items.
Definition at line 52 of file tkqueue.c.
◆ tkqueue_peek()
Get the current value from the queue without increment the queue position.
- Parameters
-
queue | The queue where to get the value. |
- Returns
- NULL when the queue is empty.
-
Pointer to the item.
Definition at line 42 of file tkqueue.c.
43{
45 return NULL;
46 }
47
49}