9b3d78573649be8d22a247ef711d36a599508cbc
2 * @file PriorityQueue.c
5 #include "cgds/PriorityQueue.h"
7 // NOTE: no init() method here,
8 // since PriorityQueue has no specific initialization
10 PriorityQueue
* _priorityqueue_new(size_t dataSize
, OrderType pType
, UInt arity
)
12 PriorityQueue
* priorityQueue
=
13 (PriorityQueue
*) safe_malloc(sizeof (PriorityQueue
));
14 priorityQueue
->heap
= _heap_new(dataSize
, pType
, arity
);
18 PriorityQueue
* priorityqueue_copy(PriorityQueue
* priorityQueue
)
20 PriorityQueue
* priorityQueueCopy
=
21 (PriorityQueue
*) safe_malloc(sizeof (PriorityQueue
));
22 priorityQueueCopy
->heap
= heap_copy(priorityQueue
->heap
);
23 return priorityQueueCopy
;
26 bool priorityqueue_empty(PriorityQueue
* priorityQueue
)
28 return heap_empty(priorityQueue
->heap
);
31 UInt
priorityqueue_size(PriorityQueue
* priorityQueue
)
33 return heap_size(priorityQueue
->heap
);
36 ItemValue
_priorityqueue_peek(PriorityQueue
* priorityQueue
)
38 return _heap_top(priorityQueue
->heap
);
41 void priorityqueue_pop(PriorityQueue
* priorityQueue
)
43 heap_pop(priorityQueue
->heap
);
46 void priorityqueue_clear(PriorityQueue
* priorityQueue
)
48 heap_clear(priorityQueue
->heap
);
51 void priorityqueue_destroy(PriorityQueue
* priorityQueue
)
53 heap_destroy(priorityQueue
->heap
);
54 safe_free(priorityQueue
);