diff options
author | jcid <devnull@localhost> | 2007-10-07 00:36:34 +0200 |
---|---|---|
committer | jcid <devnull@localhost> | 2007-10-07 00:36:34 +0200 |
commit | 93715c46a99c96d6c866968312691ec9ab0f6a03 (patch) | |
tree | 573f19ec6aa740844f53a7c0eb7114f04096bf64 /src/bitvec.h |
Initial revision
Diffstat (limited to 'src/bitvec.h')
-rw-r--r-- | src/bitvec.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/bitvec.h b/src/bitvec.h new file mode 100644 index 00000000..ab6797ce --- /dev/null +++ b/src/bitvec.h @@ -0,0 +1,36 @@ +#ifndef __BITVEC_H__ +#define __BITVEC_H__ + +#include "d_size.h" + +#define BVEC_TYPE uchar_t +#define BVEC_SIZE sizeof(BVEC_TYPE) + +typedef struct _bitvec bitvec_t; + +struct _bitvec { + BVEC_TYPE *vec; + int len; /* number of bits [1 based] */ +}; + + +/* + * Function prototypes + */ +bitvec_t *a_Bitvec_new(int bits); +void a_Bitvec_free(bitvec_t *bvec); +int a_Bitvec_get_bit(bitvec_t *bvec, int pos); +void a_Bitvec_set_bit(bitvec_t *bvec, int pos); + +/* +#define a_Bitvec_get_bit(bvec,pos) \ + ((bvec)->vec[(pos)/BVEC_SIZE] & 1 << (pos) % BVEC_SIZE) + +#define a_Bitvec_set_bit(bvec,pos) \ + ((bvec)->vec[(pos)/BVEC_SIZE] |= 1 << (pos) % BVEC_SIZE) +*/ +#define a_Bitvec_clear_bit(bvec,pos) \ + ((bvec)->vec[(pos)/BVEC_SIZE] &= ~(1 << (pos) % BVEC_SIZE)) + + +#endif /* __BITVEC_H__ */ |