libamxc
1.10.3
C Generic Data Containers
|
A queue implementation based on Array. More...
Typedefs | |
typedef amxc_array_t | amxc_aqueue_t |
The array queue structure. More... | |
typedef amxc_array_it_t | amxc_aqueue_it_t |
The array queue iterator structure. More... | |
typedef amxc_array_it_delete_t | amxc_aqueue_it_delete_t |
Definition of the item delete function. More... | |
Functions | |
AMXC_INLINE int | amxc_aqueue_new (amxc_aqueue_t **aqueue) |
Allocates an array queue. More... | |
AMXC_INLINE void | amxc_aqueue_delete (amxc_aqueue_t **aqueue, amxc_aqueue_it_delete_t func) |
Frees the previously allocated array queue. More... | |
AMXC_INLINE int | amxc_aqueue_init (amxc_aqueue_t *const aqueue) |
Initializes an array queue. More... | |
AMXC_INLINE void | amxc_aqueue_clean (amxc_aqueue_t *const aqueue, amxc_aqueue_it_delete_t func) |
Removes all items from the array queue. More... | |
AMXC_INLINE amxc_aqueue_it_t * | amxc_aqueue_add (amxc_aqueue_t *const aqueue, void *data) |
Adds data to the array queue. More... | |
AMXC_INLINE void * | amxc_aqueue_remove (amxc_aqueue_t *const aqueue) |
Removes the first added data from the queue. More... | |
AMXC_INLINE size_t | amxc_aqueue_size (const amxc_aqueue_t *const aqueue) |
Calculates the number of items in the queue. More... | |
AMXC_INLINE size_t | amxc_aqueue_is_empty (const amxc_aqueue_t *const aqueue) |
Checks that the array queue is empty. More... | |
A queue implementation based on Array.
The basic operators on a queue are add and remove.
Using the Array a queue can be created which has a initial size and can grow when needed.
When adding data to the queue, the data will be put in the first empty bucket, if no empty bucket is available, the queue (bucket array) will grow.
When removing data, the first non empty bucket is returned and all items are shifted left.
Definition of the item delete function.
A pointer to a delete function is used in the following functions amxc_aqueue_delete, amxc_aqueue_clean
Definition at line 114 of file amxc_aqueue.h.
typedef amxc_array_it_t amxc_aqueue_it_t |
The array queue iterator structure.
Definition at line 104 of file amxc_aqueue.h.
typedef amxc_array_t amxc_aqueue_t |
The array queue structure.
Definition at line 97 of file amxc_aqueue.h.
AMXC_INLINE amxc_aqueue_it_t* amxc_aqueue_add | ( | amxc_aqueue_t *const | aqueue, |
void * | data | ||
) |
Adds data to the array queue.
aqueue | a pointer to the array queue structure |
data | a pointer to the data |
Definition at line 223 of file amxc_aqueue.h.
AMXC_INLINE void amxc_aqueue_clean | ( | amxc_aqueue_t *const | aqueue, |
amxc_aqueue_it_delete_t | func | ||
) |
Removes all items from the array queue.
Removes all items from the array queue. If a delete function is provided, it is called for each item in the queue.
aqueue | a pointer to the array queue structure |
func | a pointer to a function that is called to free each item in the array queue |
Definition at line 205 of file amxc_aqueue.h.
AMXC_INLINE void amxc_aqueue_delete | ( | amxc_aqueue_t ** | aqueue, |
amxc_aqueue_it_delete_t | func | ||
) |
Frees the previously allocated array queue.
Removes all items from the array queue. If a delete function is provided, it is called for each item in the queue.
Frees the allocated memory and sets the pointer to NULL.
aqueue | a pointer to the location where the pointer to the array queue is stored |
func | a pointer to a function that is called to free each item in the array queue |
Definition at line 161 of file amxc_aqueue.h.
AMXC_INLINE int amxc_aqueue_init | ( | amxc_aqueue_t *const | aqueue | ) |
Initializes an array queue.
Initializes the array queue structure. All pointers are reset to NULL. This function is typically called for array queues that are on the stack. Allocating and initializing an array queue on the heap can be done using amxc_aqueue_new
aqueue | a pointer to the array queue structure. |
Definition at line 188 of file amxc_aqueue.h.
AMXC_INLINE size_t amxc_aqueue_is_empty | ( | const amxc_aqueue_t *const | aqueue | ) |
Checks that the array queue is empty.
aqueue | a pointer to the array queue structure |
Definition at line 271 of file amxc_aqueue.h.
AMXC_INLINE int amxc_aqueue_new | ( | amxc_aqueue_t ** | aqueue | ) |
Allocates an array queue.
Allocates and initializes memory to store an array queue. This function allocates memory from the heap. If an array queue is on the stack, it can be initialized using function amxc_aqueue_init
aqueue | a pointer to the location where the pointer to the new array queue can be stored |
Definition at line 137 of file amxc_aqueue.h.
AMXC_INLINE void* amxc_aqueue_remove | ( | amxc_aqueue_t *const | aqueue | ) |
Removes the first added data from the queue.
aqueue | a pointer to the array queue structure |
Definition at line 238 of file amxc_aqueue.h.
AMXC_INLINE size_t amxc_aqueue_size | ( | const amxc_aqueue_t *const | aqueue | ) |
Calculates the number of items in the queue.
aqueue | a pointer to the array queue structure |
Definition at line 255 of file amxc_aqueue.h.