osurs
0.0.1
|
Adaptable priority queue data structure. More...
Go to the source code of this file.
Data Structures | |
struct | PriorityQueueNode |
A node in a priority queue. More... | |
struct | PriorityQueue |
A priority queue. More... | |
Typedefs | |
typedef struct PriorityQueueNode | PriorityQueueNode |
A node in a priority queue. More... | |
typedef struct PriorityQueue | PriorityQueue |
A priority queue. More... | |
Functions | |
PriorityQueue * | priority_queue_create () |
Creates a new priority queue. More... | |
PriorityQueueNode * | priority_queue_add (PriorityQueue *queue, int priority, void *data) |
Adds an element to the priority queue. More... | |
void * | priority_queue_peek (PriorityQueue *queue) |
Returns the data of the element at the front of the priority queue. More... | |
void * | priority_queue_poll (PriorityQueue *queue) |
Removes and returns the data of the element at the front of the priority queue. More... | |
void * | priority_queue_remove (PriorityQueue *queue, PriorityQueueNode *node) |
Removes a specific element from the priority queue, frees the node, and returns its data. More... | |
void | priority_queue_change_priority (PriorityQueue *queue, PriorityQueueNode *node, int new_priority) |
Changes the priority of a specific element in the priority queue. More... | |
void | priority_queue_free (PriorityQueue *queue) |
Frees a priority queue and all of its elements. More... | |
Adaptable priority queue data structure.
This file defines an adaptable priority queue data structure and its associated functions. An adaptable priority queue is a type of priority queue that allows the priorities of its elements to be changed after they have been added to the queue, using so-called location-aware entries.
Adaptable priority queues are typically implemented using a heap data structure, where the priorities of elements are used to determine the order in which they are stored in the heap. The heap property ensures that the element with the highest priority is always at the top of the heap, making it easy to extract the highest-priority element from the queue.
typedef struct PriorityQueue PriorityQueue |
A priority queue.
typedef struct PriorityQueueNode PriorityQueueNode |
A node in a priority queue.
PriorityQueueNode* priority_queue_add | ( | PriorityQueue * | queue, |
int | priority, | ||
void * | data | ||
) |
Adds an element to the priority queue.
queue | The priority queue to add the element to |
priority | The priority of the element being added |
data | The data of the element being added |
void priority_queue_change_priority | ( | PriorityQueue * | queue, |
PriorityQueueNode * | node, | ||
int | new_priority | ||
) |
Changes the priority of a specific element in the priority queue.
queue | The priority queue |
node | The node whose priority is being changed |
new_priority | The new priority of the node |
PriorityQueue* priority_queue_create | ( | ) |
Creates a new priority queue.
void priority_queue_free | ( | PriorityQueue * | queue | ) |
Frees a priority queue and all of its elements.
queue | The priority queue to be freed |
void* priority_queue_peek | ( | PriorityQueue * | queue | ) |
Returns the data of the element at the front of the priority queue.
queue | The priority queue |
void* priority_queue_poll | ( | PriorityQueue * | queue | ) |
Removes and returns the data of the element at the front of the priority queue.
queue | The priority queue |
void* priority_queue_remove | ( | PriorityQueue * | queue, |
PriorityQueueNode * | node | ||
) |
Removes a specific element from the priority queue, frees the node, and returns its data.
queue | The priority queue |
node | The node to remove from the priority queue |