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