-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitset.h
38 lines (25 loc) · 1.04 KB
/
bitset.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef BITSET_H
#define BITSET_H
#include <stddef.h>
struct bitset;
struct bitset *bitset_create(size_t num_elements, bool init_value);
bool bitset_get(struct bitset *bitset, size_t idx);
void bitset_set(struct bitset *bitset, size_t idx, bool value);
size_t bitset_length(struct bitset *bitset);
struct bitset_iter {
struct bitset *bitset;
bool value;
size_t idx;
};
struct bitset_iter bitset_iter(struct bitset *bitset, size_t start, bool value);
// returns `false` when finished (idx is undefined as soon as this occurs)
bool bitset_iter_next(struct bitset_iter *iter, size_t *idx);
unsigned long long bitset_all(struct bitset *bitset, bool value);
unsigned long long bitset_any(struct bitset *bitset, bool value);
unsigned long long bitset_popcnt(struct bitset *bitset);
unsigned long long bitset_lzcnt(struct bitset *bitset);
unsigned long long bitset_tzcnt(struct bitset *bitset);
unsigned long long bitset_as_ull(struct bitset *bitset);
void bitset_clear(struct bitset *bitset, bool value);
void bitset_free(struct bitset **bitset);
#endif