#include <stdbool.h>
#include "Task.h"
Go to the source code of this file.
◆ MAX_SENSORS
◆ PQInit()
Initializes the priority queue.
- Parameters
-
Definition at line 3 of file PriorityQueue.c.
◆ PQIsEmpty()
Checks if the priority queue is empty.
- Parameters
-
- Returns
- True if the queue is empty, false otherwise.
Definition at line 62 of file PriorityQueue.c.
◆ PQIsFull()
Checks if the priority queue is full.
- Parameters
-
- Returns
- True if the queue is full, false otherwise.
Definition at line 66 of file PriorityQueue.c.
◆ PQPeek()
Peeks at the highest priority task in the priority queue without removing it.
- Parameters
-
pq | Pointer to the PriorityQueue structure. |
task | Pointer to the Task structure to store the peeked task. |
- Returns
- True if a task was successfully peeked, false if the queue is empty.
Definition at line 56 of file PriorityQueue.c.
56 {
59 return true;
60}
bool PQIsEmpty(PriorityQueue *pq)
Checks if the priority queue is empty.
PQNode nodes[MAX_SENSORS+1]
◆ PQPop()
Pops the highest priority task from the priority queue.
- Parameters
-
pq | Pointer to the PriorityQueue structure. |
task | Pointer to the Task structure to store the popped task. |
- Returns
- True if a task was successfully popped, false if the queue is empty.
Definition at line 48 of file PriorityQueue.c.
48 {
53 return true;
54}
void heapifyDown(PriorityQueue *pq, int index)
Restores the heap property by moving the node at the given index down.
◆ PQPush()
Pushes a task with a given priority onto the priority queue.
- Parameters
-
pq | Pointer to the PriorityQueue structure. |
task | The task to push onto the queue. |
priority | The priority of the task. |
- Returns
- True if the task was successfully pushed, false if the queue is full.
Definition at line 41 of file PriorityQueue.c.
41 {
45 return true;
46}
void heapifyUp(PriorityQueue *pq, int index)
Restores the heap property by moving the node at the given index up.
bool PQIsFull(PriorityQueue *pq)
Checks if the priority queue is full.