chiark / gitweb /
e348c64649aaf7096caec7ce5756702498582df7
[elogind.git] / src / basic / prioq.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5   This file is part of systemd.
6
7   Copyright 2013 Lennart Poettering
8 ***/
9
10 #include <stdbool.h>
11
12 #include "hashmap.h"
13 #include "macro.h"
14
15 typedef struct Prioq Prioq;
16
17 #define PRIOQ_IDX_NULL ((unsigned) -1)
18
19 Prioq *prioq_new(compare_func_t compare);
20 Prioq *prioq_free(Prioq *q);
21 int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func);
22
23 int prioq_put(Prioq *q, void *data, unsigned *idx);
24 int prioq_remove(Prioq *q, void *data, unsigned *idx);
25 int prioq_reshuffle(Prioq *q, void *data, unsigned *idx);
26
27 void *prioq_peek(Prioq *q) _pure_;
28 void *prioq_pop(Prioq *q);
29
30 unsigned prioq_size(Prioq *q) _pure_;
31 bool prioq_isempty(Prioq *q) _pure_;