lsquic_set.h revision a74702c6
1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_set.h -- A set implementation.
450aadb33SDmitri Tikhonov *
550aadb33SDmitri Tikhonov * There are two sets of APIs: one for four- and the other for eight-byte
650aadb33SDmitri Tikhonov * integers.
750aadb33SDmitri Tikhonov */
850aadb33SDmitri Tikhonov
950aadb33SDmitri Tikhonov#ifndef LSQUIC_SET_H
1050aadb33SDmitri Tikhonov#define LSQUIC_SET_H 1
1150aadb33SDmitri Tikhonov
1250aadb33SDmitri Tikhonov#include <stdint.h>
1350aadb33SDmitri Tikhonov
1450aadb33SDmitri Tikhonovstruct lsquic_set32_elem;
1550aadb33SDmitri Tikhonov
1650aadb33SDmitri Tikhonovtypedef struct lsquic_set32 {
1750aadb33SDmitri Tikhonov    struct lsquic_set32_elem   *elems;
1850aadb33SDmitri Tikhonov    uint64_t                    lowset; /* Bitmask for values 0 - 63 */
1950aadb33SDmitri Tikhonov    int                         n_elems, n_alloc;
2050aadb33SDmitri Tikhonov} lsquic_set32_t;
2150aadb33SDmitri Tikhonov
2250aadb33SDmitri Tikhonovvoid
2350aadb33SDmitri Tikhonovlsquic_set32_init (struct lsquic_set32 *);
2450aadb33SDmitri Tikhonov
2550aadb33SDmitri Tikhonovvoid
2650aadb33SDmitri Tikhonovlsquic_set32_cleanup (struct lsquic_set32 *);
2750aadb33SDmitri Tikhonov
2850aadb33SDmitri Tikhonovint
2950aadb33SDmitri Tikhonovlsquic_set32_add (struct lsquic_set32 *, uint32_t value);
3050aadb33SDmitri Tikhonov
3150aadb33SDmitri Tikhonov/* Returns true if set contaims `value', false otherwise */
3250aadb33SDmitri Tikhonovint
3350aadb33SDmitri Tikhonovlsquic_set32_has (const struct lsquic_set32 *, uint32_t value);
3450aadb33SDmitri Tikhonov
3550aadb33SDmitri Tikhonovstruct lsquic_set64_elem;
3650aadb33SDmitri Tikhonov
3750aadb33SDmitri Tikhonovtypedef struct lsquic_set64 {
3850aadb33SDmitri Tikhonov    struct lsquic_set64_elem   *elems;
3950aadb33SDmitri Tikhonov    uint64_t                    lowset; /* Bitmask for values 0 - 63 */
4050aadb33SDmitri Tikhonov    int                         n_elems, n_alloc;
4150aadb33SDmitri Tikhonov} lsquic_set64_t;
4250aadb33SDmitri Tikhonov
4350aadb33SDmitri Tikhonovvoid
4450aadb33SDmitri Tikhonovlsquic_set64_init (struct lsquic_set64 *);
4550aadb33SDmitri Tikhonov
4650aadb33SDmitri Tikhonovvoid
4750aadb33SDmitri Tikhonovlsquic_set64_cleanup (struct lsquic_set64 *);
4850aadb33SDmitri Tikhonov
4950aadb33SDmitri Tikhonovint
5050aadb33SDmitri Tikhonovlsquic_set64_add (struct lsquic_set64 *, uint64_t value);
5150aadb33SDmitri Tikhonov
5250aadb33SDmitri Tikhonov/* Returns true if set contaims `value', false otherwise */
5350aadb33SDmitri Tikhonovint
5450aadb33SDmitri Tikhonovlsquic_set64_has (const struct lsquic_set64 *, uint64_t value);
5550aadb33SDmitri Tikhonov
5650aadb33SDmitri Tikhonov#endif
57