2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * @author Christian Wuerdig
24 * @brief Implementation of a priority queue. This is the ported version of the
25 * original Java implementation by Matthias Braun.
28 #ifndef FIRM_ADT_PQUEUE_H
29 #define FIRM_ADT_PQUEUE_H
31 typedef struct _pqueue_t pqueue;
34 * Creates a new priority queue.
35 * @return A priority queue of initial length 0.
37 pqueue *new_pqueue(void);
40 * Frees all memory allocated by the priority queue.
41 * @param q The priority queue to destroy.
43 void del_pqueue(pqueue *q);
46 * Inserts a new element into a priority queue.
47 * @param q The priority queue the element should be inserted to.
48 * @param data The actual data which should be stored in the queue.
49 * @param key The priority for the data.
51 void pqueue_put(pqueue *q, void *data, int key);
54 * Returns and removes the first element, ie. that one with the highest priority, from the queue.
55 * @param q The priority queue.
56 * @return The first element of the queue. Asserts if queue is empty.
58 void *pqueue_get(pqueue *q);
61 * Get the length of the priority queue.
62 * @param q The priority queue.
63 * @return The length of the queue.
65 int pqueue_length(pqueue *q);
68 * Returns true if queue is empty.
69 * @param q The priority queue.
70 * @return 1 if the queue is empty, 0 otherwise.
72 int pqueue_empty(pqueue *q);