1 #ifndef foopulsecoreprioqhfoo
2 #define foopulsecoreprioqhfoo
5 This file is part of PulseAudio.
7 Copyright 2008 Lennart Poettering
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.
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.
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
27 #include <pulsecore/macro.h>
28 #include <pulsecore/idxset.h>
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
34 typedef struct pa_prioq pa_prioq;
35 typedef struct pa_prioq_item pa_prioq_item;
37 /* Instantiate a new prioq with the specified comparison functions */
38 pa_prioq* pa_prioq_new(pa_compare_func_t compare_func);
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);
43 /* Store a new item in the prioq. */
44 pa_prioq_item* pa_prioq_put(pa_prioq *q, void* data);
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);
49 /* Get the item on the top of the queue, and remove it from thq queue */
50 void* pa_prioq_pop(pa_prioq*q);
52 /* Remove an arbitrary from theq prioq, returning it's data */
53 void* pa_prioq_remove(pa_prioq*q, pa_prioq_item *i);
55 /* The priority of an item was modified. Adjustthe queue to that */
56 void pa_prioq_reshuffle(pa_prioq *q, pa_prioq_item *i);
58 /* Return the current number of items in the prioq */
59 unsigned pa_prioq_size(pa_prioq*s);
61 /* Return TRUE of the prioq is empty */
62 pa_bool_t pa_prioq_isempty(pa_prioq *s);