Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
PriorityQueue.h
Go to the documentation of this file.
1#ifndef RENSSELAERMOTORSPORT_PRIORITYQUEUE_H
2#define RENSSELAERMOTORSPORT_PRIORITYQUEUE_H
3
4#include <stdbool.h>
5
6#include "Task.h"
7
8#define MAX_SENSORS 10
9
10typedef struct {
13} PQNode;
14
15typedef struct {
16 // Use 1-based indexing for easier parent/child calculations
17 PQNode nodes[MAX_SENSORS + 1];
18 int size;
20
26void PQInit(PriorityQueue* pq);
27
36bool PQPush(PriorityQueue* pq, Task task, int priority);
37
45bool PQPop(PriorityQueue* pq, Task* task);
46
47
55bool PQPeek(PriorityQueue* pq, Task* task);
56
63bool PQIsEmpty(PriorityQueue* pq);
64
71bool PQIsFull(PriorityQueue* pq);
72
73#endif // RENSSELAERMOTORSPORT_PRIORITYQUEUE_H
bool PQPeek(PriorityQueue *pq, Task *task)
Peeks at the highest priority task in the priority queue without removing it.
Definition: PriorityQueue.c:56
bool PQIsEmpty(PriorityQueue *pq)
Checks if the priority queue is empty.
Definition: PriorityQueue.c:62
#define MAX_SENSORS
Definition: PriorityQueue.h:8
bool PQIsFull(PriorityQueue *pq)
Checks if the priority queue is full.
Definition: PriorityQueue.c:66
bool PQPop(PriorityQueue *pq, Task *task)
Pops the highest priority task from the priority queue.
Definition: PriorityQueue.c:48
bool PQPush(PriorityQueue *pq, Task task, int priority)
Pushes a task with a given priority onto the priority queue.
Definition: PriorityQueue.c:41
void PQInit(PriorityQueue *pq)
Initializes the priority queue.
Definition: PriorityQueue.c:3
int priority
Definition: PriorityQueue.h:11
Task task
Definition: PriorityQueue.h:12
Definition: Task.h:8