Data Structures Lerax  v3.0-102-gaf18
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
pqueue.h
Go to the documentation of this file.
1
12
13#ifndef PQUEUE_H
14#ifndef PQUEUE_SIZE
15#define PQUEUE_SIZE 10
16#endif
17
18#define HEAP_EMPTY_CELL -1
19
23struct PQueue {
25 int size;
26};
27
28
32typedef struct PQueue PQueue;
33
41
49void pqueue_insert(PQueue *pq, int x);
50
59
68void pqueue_increase_keys(PQueue *pq, int k, int v);
69
78
86
94
103
104#endif
PQueue * pqueue_create()
Creates an empty priority queue.
void pqueue_print(PQueue *pq)
Prints the elements of a priority queue to the console.
void pqueue_println(PQueue *pq)
Prints the elements of a priority queue to the console, followed by a newline character.
int pqueue_maximum(PQueue *pq)
Returns the maximum element in the priority queue without extracting it.
int pqueue_extract_max(PQueue *pq)
Extracts the maximum element from the priority queue.
void pqueue_insert(PQueue *pq, int x)
Inserts an element into the priority queue.
void pqueue_increase_keys(PQueue *pq, int k, int v)
Increases the key of an element in the priority queue.
void pqueue_free(PQueue *pq)
Frees the memory allocated for a priority queue.
#define PQUEUE_SIZE
Definition pqueue.h:15
A priority queue implementation using a binary heap.
Definition pqueue.h:23
int size
Definition pqueue.h:25
int heap[PQUEUE_SIZE]
Definition pqueue.h:24