lsquic_set.h revision 06b2a236
1/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_set.h -- A set implementation.
4 *
5 * There are two sets of APIs: one for four- and the other for eight-byte
6 * integers.
7 */
8
9#ifndef LSQUIC_SET_H
10#define LSQUIC_SET_H 1
11
12#include <stdint.h>
13
14struct lsquic_set32_elem;
15
16typedef struct lsquic_set32 {
17    struct lsquic_set32_elem   *elems;
18    uint64_t                    lowset; /* Bitmask for values 0 - 63 */
19    int                         n_elems, n_alloc;
20} lsquic_set32_t;
21
22void
23lsquic_set32_init (struct lsquic_set32 *);
24
25void
26lsquic_set32_cleanup (struct lsquic_set32 *);
27
28int
29lsquic_set32_add (struct lsquic_set32 *, uint32_t value);
30
31/* Returns true if set contaims `value', false otherwise */
32int
33lsquic_set32_has (const struct lsquic_set32 *, uint32_t value);
34
35struct lsquic_set64_elem;
36
37typedef struct lsquic_set64 {
38    struct lsquic_set64_elem   *elems;
39    uint64_t                    lowset; /* Bitmask for values 0 - 63 */
40    int                         n_elems, n_alloc;
41} lsquic_set64_t;
42
43void
44lsquic_set64_init (struct lsquic_set64 *);
45
46void
47lsquic_set64_cleanup (struct lsquic_set64 *);
48
49int
50lsquic_set64_add (struct lsquic_set64 *, uint64_t value);
51
52/* Returns true if set contaims `value', false otherwise */
53int
54lsquic_set64_has (const struct lsquic_set64 *, uint64_t value);
55
56#endif
57