properly mark symbols in the public API to be exported. This allows us to use -fvisib...
[libfirm] / include / libfirm / adt / pqueue.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @date    18.04.2007
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.
26  * @version $Id$
27  */
28 #ifndef FIRM_ADT_PQUEUE_H
29 #define FIRM_ADT_PQUEUE_H
30
31 #include "../begin.h"
32
33 typedef struct _pqueue_t pqueue_t;
34
35 /**
36  * Creates a new priority queue.
37  * @return A priority queue of initial length 0.
38  */
39 pqueue_t *new_pqueue(void);
40
41 /**
42  * Frees all memory allocated by the priority queue.
43  * @param q   The priority queue to destroy.
44  */
45 void del_pqueue(pqueue_t *q);
46
47 /**
48  * Inserts a new element into a priority queue.
49  * @param q         The priority queue the element should be inserted to.
50  * @param data      The actual data which should be stored in the queue.
51  * @param priority  The priority for the data.
52  */
53 void pqueue_put(pqueue_t *q, void *data, int priority);
54
55 /**
56  * Returns and removes the first element, ie. that one with the highest priority, from the queue.
57  * @param q   The priority queue.
58  * @return The first element of the queue. Asserts if queue is empty.
59  */
60 void *pqueue_pop_front(pqueue_t *q);
61
62 /**
63  * Get the length of the priority queue.
64  * @param q   The priority queue.
65  * @return The length of the queue.
66  */
67 int pqueue_length(const pqueue_t *q);
68
69 /**
70  * Returns true if queue is empty.
71  * @param q   The priority queue.
72  * @return 1 if the queue is empty, 0 otherwise.
73  */
74 int pqueue_empty(const pqueue_t *q);
75
76 #include "../end.h"
77
78 #endif