]> code.delx.au - pulseaudio/blob - src/pulsecore/prioq.h
fd3550b73e20c66dcf3395e2f879c86ed526a3ce
[pulseaudio] / src / pulsecore / prioq.h
1 #ifndef foopulsecoreprioqhfoo
2 #define foopulsecoreprioqhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2008 Lennart Poettering
8
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
13
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include <inttypes.h>
26
27 #include <pulsecore/macro.h>
28 #include <pulsecore/idxset.h>
29
30 /* A heap-based priority queue. Removal and insertion is O(log
31 * n). Removal can happen a the top or at any position referenced by a
32 * pa_prioq_item. */
33
34 typedef struct pa_prioq pa_prioq;
35 typedef struct pa_prioq_item pa_prioq_item;
36
37 /* Instantiate a new prioq with the specified comparison functions */
38 pa_prioq* pa_prioq_new(pa_compare_func_t compare_func);
39
40 /* Free the prioq. When the prioq is not empty the specified function is called for every entry contained */
41 void pa_prioq_free(pa_prioq *q, pa_free2_cb_t free_cb, void *userdata);
42
43 /* Store a new item in the prioq. */
44 pa_prioq_item* pa_prioq_put(pa_prioq *q, void* data);
45
46 /* Get the item on the top of the queue, but don't remove it from the queue*/
47 void* pa_prioq_peek(pa_prioq*q);
48
49 /* Get the item on the top of the queue, and remove it from thq queue */
50 void* pa_prioq_pop(pa_prioq*q);
51
52 /* Remove an arbitrary from theq prioq, returning it's data */
53 void* pa_prioq_remove(pa_prioq*q, pa_prioq_item *i);
54
55 /* The priority of an item was modified. Adjustthe queue to that */
56 void pa_prioq_reshuffle(pa_prioq *q, pa_prioq_item *i);
57
58 /* Return the current number of items in the prioq */
59 unsigned pa_prioq_size(pa_prioq*s);
60
61 /* Return TRUE of the prioq is empty */
62 pa_bool_t pa_prioq_isempty(pa_prioq *s);
63
64 #endif