forked from EddyRivasLab/easel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesl_bitfield.h
44 lines (32 loc) · 867 Bytes
/
esl_bitfield.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
39
40
41
#ifndef eslBITFIELD_INCLUDED
#define eslBITFIELD_INCLUDED
#include <esl_config.h>
#include "easel.h"
typedef struct {
uint64_t *b; // packed storage of flags
int nb; // number of flags
} ESL_BITFIELD;
static inline void
esl_bitfield_Set(ESL_BITFIELD *b, int i)
{
b->b[i/64] |= (1ull << (i%64));
}
static inline void
esl_bitfield_Clear(ESL_BITFIELD *b, int i)
{
b->b[i/64] &= ~(1ull << (i%64));
}
static inline void
esl_bitfield_Toggle(ESL_BITFIELD *b, int i)
{
b->b[i/64] ^= (1ull << (i%64));
}
static inline int
esl_bitfield_IsSet(const ESL_BITFIELD *b, int i)
{
return ((b->b[i/64] & (1ull << (i%64))) ? TRUE : FALSE);
}
extern ESL_BITFIELD *esl_bitfield_Create (int nb);
extern int esl_bitfield_Count (const ESL_BITFIELD *b);
extern void esl_bitfield_Destroy(ESL_BITFIELD *b);
#endif //eslBITFIELD_INCLUDED