added cast to avoid compiler warning
[libfirm] / ir / adt / pqueue.h
1 /**
2 * @file    pqueue.h
3 * @date    18.04.2007
4 * @author  Christian Wuerdig
5 * @brief   Implementation of a priority queue. This is the ported version of the
6 *          original Java implementation by Matthias Braun.
7 * @version $Id$
8 */
9
10 #ifndef _PQUEUE_H_
11 #define _PQUEUE_H_
12
13 typedef struct _pqueue_t pqueue;
14
15 /**
16  * Creates a new priority queue.
17  * @return A priority queue of initial length 0.
18  */
19 pqueue *new_pqueue(void);
20
21 /**
22  * Frees all memory allocated by the priority queue.
23  * @param q   The priority queue to destroy.
24  */
25 void del_pqueue(pqueue *q);
26
27 /**
28  * Inserts a new element into a priority queue.
29  * @param q      The priority queue the element should be inserted to.
30  * @param data   The actual data which should be stored in the queue.
31  * @param key    The priority for the data.
32  */
33 void pqueue_put(pqueue *q, void *data, double key);
34
35 /**
36  * Returns and removes the first element, ie. that one with the highest priority, from the queue.
37  * @param q   The priority queue.
38  * @return The first element of the queue. Asserts if queue is empty.
39  */
40 void *pqueue_get(pqueue *q);
41
42 /**
43  * Get the length of the priority queue.
44  * @param q   The priority queue.
45  * @return The length of the queue.
46  */
47 int pqueue_length(pqueue *q);
48
49 /**
50  * Returns true if queue is empty.
51  * @param q   The priority queue.
52  * @return 1 if the queue is empty, 0 otherwise.
53  */
54 int pqueue_empty(pqueue *q);
55
56 #endif /* _PQUEUE_H_ */