The LevAWC Project
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
pqueue.c
Go to the documentation of this file.
1 /*
2  * _____
3  * ANSI / ___/
4  * / /__
5  * \___/
6  *
7  * Filename: pqueue.c
8  * Author : Kyle Loudon/Dan Levin
9  * Date : Fri Mar 22 12:40:45 GMT 2013
10  * Version : 0.51
11  * ---
12  * Description: A priority queue ADT - in ANSI C.
13  *
14  * Date Revision message
15  * 150331 This code ready for version 0.51
16  *
17  */
18 
23 #include <stdio.h>
24 #include <stdlib.h>
25 
26 #include "pqueue.h"
27 
28 /* --- PUBLIC FUNCTION DEFINITIONS --- */
29 /* --- Function: PQueue PQUEUEinit(int (*compare)(const void *key1, const void* key2), void (*destroy)(void *data)) --- */
30 PQueue PQUEUEinit(int (*compare)(const void *key1, const void* key2), void (*destroy)(void *data))
31 {
32  return HEAPinit(compare, destroy);
33 }
34 
35 /* --- Function: void PQUEUEdestroy(PQueue pq) --- */
37 {
38  HEAPdestroy(pq);
39 }
40 
41 /* --- Function: int PQUEUEinsert(PQueue pq, const void *data) --- */
42 int PQUEUEinsert(PQueue pq, const void *data)
43 {
44  return HEAPinsert(pq, data);
45 }
46 
47 /* --- Function: int PQUEUEextract(PQueue pq, void **data) --- */
48 int PQUEUEextract(PQueue pq, void **data)
49 {
50  return HEAPextract(pq, data);
51 }
52 
53 /* --- Function: void *PQUEUEpeek(const PQueue pq) --- */
54 const void *PQUEUEpeek(const PQueue pq)
55 {
56  return HEAPpeek(pq);
57 }
58 
59 /* --- Function: int PQUEUEsize(PQueue pq) --- */
61 {
62  return HEAPsize(pq);
63 }
64 
65 /* --- Function: void PQUEUEprint(PQueue pq, void (*callback)(const void *data)) --- */
66 void PQUEUEprint(PQueue pq, void (*callback)(const void *data))
67 {
68  HEAPprint(pq, callback);
69 }