The FIFO queue.
More...
Go to the source code of this file.
|
typedef struct _QueueData | QueueData |
| QueueData is the data type for the container private information. More...
|
|
The FIFO queue.
Definition in file queue.h.
QueueData is the data type for the container private information.
Definition at line 11 of file queue.h.
int32_t QueueInit |
( |
Queue ** |
ppObj | ) |
|
The constructor for Queue.
- Parameters
-
ppObj | The double pointer to the to be constructed queue |
- Return values
-
SUCC | |
ERR_NOMEM | Insufficient memory for queue construction |
void QueueDeinit |
( |
Queue ** |
ppObj | ) |
|
The destructor for Queue.
If the custom resource clean method is set, it also runs the clean method for all the items.
- Parameters
-
ppObj | The double pointer to the to be destructed queue |
int32_t QueuePush |
( |
Queue * |
self, |
|
|
Item |
item |
|
) |
| |
Insert an item to the tail of the queue.
This function inserts an item to the tail of the queue with the corresponding queue size extension.
- Parameters
-
self | The pointer to Queue structure |
item | The designated item |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_NOMEM | Insufficient memory for queue extension |
int32_t QueuePop |
( |
Queue * |
self | ) |
|
Delete item from top of the queue.
This function deletes item from top of the queue. If the custom resource clean method is set, it also runs the clean method for the deleted item.
- Parameters
-
self | The pointer to Queue structure |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_IDX | Empty queue |
int32_t QueueFront |
( |
Queue * |
self, |
|
|
Item * |
pItem |
|
) |
| |
Retrieve item from the head of the queue.
This function retrieves item from the head of the queue. If the queue is not empty, the item is returned by the second parameter. Otherwise, the error code is returned and the second parameter is updated with NULL.
- Parameters
-
self | The pointer to Queue structure |
pItem | The pointer to the returned item |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_IDX | Empty queue |
ERR_GET | Invalid parameter to store returned item |
int32_t QueueBack |
( |
Queue * |
self, |
|
|
Item * |
pItem |
|
) |
| |
Retrieve item from the tail of the queue.
This function retrieves item from the tail of the queue. If the queue is not empty, the item is returned by the second parameter. Otherwise, the error code is returned and the second parameter is updated with NULL.
- Parameters
-
self | The pointer to Queue structure |
pItem | The pointer to the returned item |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_IDX | Empty queue |
ERR_GET | Invalid parameter to store returned item |
int32_t QueueSize |
( |
Queue * |
self | ) |
|
Return the number of stored items.
- Parameters
-
self | The pointer to Queue structure |
- Returns
- The number of items
- Return values
-
ERR_NOINIT | Uninitialized container |
int32_t QueueSetDestroy |
( |
Queue * |
self, |
|
|
void(*)(Item) |
pFunc |
|
) |
| |
Set the custom item resource clean method.
- Parameters
-
self | The pointer to Queue structure |
pFunc | The function pointer to the custom method |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |