35 lines
1.3 KiB
C
35 lines
1.3 KiB
C
#ifndef BLUELIB_BITMAP_H_
|
|
#define BLUELIB_BITMAP_H_
|
|
|
|
#include <stdbool.h>
|
|
|
|
typedef unsigned long b_bitmap_word;
|
|
|
|
#define Z__B_BITS_PER_WORD (8 * sizeof(b_bitmap_word))
|
|
#define Z__B_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
|
#define B_BITMAP_WORDS(nbits) Z__B_DIV_ROUND_UP(nbits, Z__B_BITS_PER_WORD)
|
|
#define B_BITMAP_NPOS ((unsigned int)-1)
|
|
|
|
#define B_DECLARE_BITMAP(name, nbits) b_bitmap_word name[B_BITMAP_WORDS(nbits)]
|
|
|
|
extern void b_bitmap_zero(b_bitmap_word *map, unsigned long nbits);
|
|
extern void b_bitmap_fill(b_bitmap_word *map, unsigned long nbits);
|
|
extern void b_bitmap_set(b_bitmap_word *map, unsigned long bit);
|
|
extern void b_bitmap_clear(b_bitmap_word *map, unsigned long bit);
|
|
extern bool b_bitmap_check(const b_bitmap_word *map, unsigned long bit);
|
|
|
|
extern unsigned int b_bitmap_count_set(const b_bitmap_word *map, unsigned long nbits);
|
|
extern unsigned int b_bitmap_count_clear(const b_bitmap_word *map, unsigned long nbits);
|
|
|
|
extern unsigned int b_bitmap_highest_set(const b_bitmap_word *map, unsigned long nbits);
|
|
extern unsigned int b_bitmap_highest_clear(const b_bitmap_word *map, unsigned long nbits);
|
|
extern unsigned int b_bitmap_lowest_set(const b_bitmap_word *map, unsigned long nbits);
|
|
extern unsigned int b_bitmap_lowest_clear(const b_bitmap_word *map, unsigned long nbits);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif
|