-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpqheap.h
More file actions
executable file
·66 lines (38 loc) · 1.55 KB
/
Copy pathpqheap.h
File metadata and controls
executable file
·66 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _PQHEAP_H
#define _PQHEAP_H
/* includes the definition of a pqueue element */
#include "basictype.h"
/**************************************************************
Priority queue of elements of type elemType.
elemType assumed to have defined a function getPriority(elemType x)
***************************************************************/
typedef struct {
/* A pointer to an array of elements */
elemType* elements;
/* The number of elements currently in the queue */
unsigned int cursize;
/* The maximum number of elements the queue can currently hold */
unsigned int maxsize;
} PQueue;
/* create and initialize a pqueue and return it */
PQueue* PQ_initialize();
/* delete the pqueue and free its space */
void PQ_delete(PQueue* pq);
/* Is it empty? */
int PQ_isEmpty(PQueue* pq);
/* Return the nb of elements currently in the queue */
unsigned int PQ_size(PQueue* pq);
/* Set *elt to the min element in the queue */
int PQ_min(PQueue* pq, elemType* elt);
/* Set *elt to the min element in the queue and delete it from queue */
int PQ_extractMin(PQueue* pq, elemType* elt);
/* Delete the min element; same as PQ_extractMin, but ignore the value extracted */
int PQ_deleteMin(PQueue* pq);
/* Insert */
void PQ_insert(PQueue* pq, elemType elt);
/* Delete the min element and insert the new item x; by doing a delete
and an insert together you can save a heapify() call */
void PQ_deleteMinAndInsert(PQueue* pq, elemType x);
/* print the elements in the queue */
void PQ_print(PQueue* pq);
#endif // _PQUEUE_HEAP_H