-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
66 lines (51 loc) · 1.47 KB
/
main.c
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
#include "priorityQueue.h"
void pqEnqueue(PriorityQueue *pq, PRIORITY_DATA_TYPE priority);
LinkedListNode *pqPeek(PriorityQueue *pq);
LinkedListNode *pqGet(PriorityQueue *pq, int position);
PRIORITY_DATA_TYPE pqDequeue(PriorityQueue *pq);
int main()
{
PriorityQueue pq;
priorityQueueInit(&pq);
pqEnqueue(&pq, 14);
pqEnqueue(&pq, 5);
pqEnqueue(&pq, 9);
pqEnqueue(&pq, 0);
pqEnqueue(&pq, 10);
printf("el valor mas pequeño es: %d\n", pqPeek(&pq)->priority);
for (int i = 0; i < priorityQueueLenght(&pq); i++)
{
linkedListNodeDisplay(pqGet(&pq, i));
}
printf("--- Pruebas de eliminacion ---\n");
printf("%d eliminado\n", pqDequeue(&pq));
printf("%d eliminado\n", pqDequeue(&pq));
printf("%d eliminado\n", pqDequeue(&pq));
printf("%d eliminado\n", pqDequeue(&pq));
printf("el valor mas pequeño es: %d\n", pqPeek(&pq)->priority);
for (int i = 0; i < priorityQueueLenght(&pq); i++)
{
linkedListNodeDisplay(pqGet(&pq, i));
}
priorityQueueFree(&pq);
return 0;
}
void pqEnqueue(PriorityQueue *pq, PRIORITY_DATA_TYPE priority)
{
priorityQueueEnqueue(pq, linkedListNodeCreate(priority));
}
LinkedListNode *pqPeek(PriorityQueue *pq)
{
return priorityQueuePeek(pq);
}
LinkedListNode *pqGet(PriorityQueue *pq, int position)
{
return priorityQueueGet(pq, position);
}
PRIORITY_DATA_TYPE pqDequeue(PriorityQueue *pq)
{
LinkedListNode *a = priorityQueueDequeue(pq);
PRIORITY_DATA_TYPE priority = a->priority;
free(a);
return priority;
}