The priority queue implemented with binary heap.
More...
Go to the source code of this file.
|
typedef struct _PriorityQueueData | PriorityQueueData |
| PriorityQueueData is the data type for the container private information. More...
|
|
The priority queue implemented with binary heap.
Definition in file priority_queue.h.
PriorityQueueData is the data type for the container private information.
Definition at line 11 of file priority_queue.h.
The constructor for PriorityQueue.
- Parameters
-
ppObj | The double pointer to the to be constructed queue |
- Return values
-
SUCC | |
ERR_NOMEM | Insufficient memory for queue construction |
The destructor for PriorityQueue.
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 |
Push an item onto the queue.
This function pushes an item onto the queue with the corresponding queue size extension.
- Parameters
-
self | The pointer to PriorityQueue structure |
item | The designated item |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_NOMEM | Insufficient memory for queue extension |
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
-
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
ERR_IDX | Empty queue |
Retrieve item from top of the queue.
This function retrieves item from top 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 PriorityQueue 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 |
Return the number of stored items.
- Parameters
-
- Returns
- The number of items
- Return values
-
ERR_NOINIT | Uninitialized container |
int32_t PriorityQueueSetCompare |
( |
PriorityQueue * |
self, |
|
|
int32_t(*)(Item, Item) |
pFunc |
|
) |
| |
Set the custom item comparison method.
- Parameters
-
self | The pointer to PriorityQueue structure |
pFunc | The function pointer to the custom method |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |
int32_t PriorityQueueSetDestroy |
( |
PriorityQueue * |
self, |
|
|
void(*)(Item) |
pFunc |
|
) |
| |
Set the custom item resource clean method.
- Parameters
-
self | The pointer to PriorityQueue structure |
pFunc | The function pointer to the custom method |
- Return values
-
SUCC | |
ERR_NOINIT | Uninitialized container |