ds: bitmap: convert from a static array to a b_object
This commit is contained in:
@@ -1,35 +1,40 @@
|
||||
#ifndef BLUELIB_BITMAP_H_
|
||||
#define BLUELIB_BITMAP_H_
|
||||
#ifndef BLUE_DS_BITMAP_H_
|
||||
#define BLUE_DS_BITMAP_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef unsigned long b_bitmap_word;
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#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_TYPE_BITMAP (b_bitmap_get_type())
|
||||
|
||||
#define B_DECLARE_BITMAP(name, nbits) b_bitmap_word name[B_BITMAP_WORDS(nbits)]
|
||||
B_DECLARE_TYPE(b_bitmap);
|
||||
|
||||
BLUE_API void b_bitmap_zero(b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API void b_bitmap_fill(b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API void b_bitmap_set(b_bitmap_word *map, unsigned long bit);
|
||||
BLUE_API void b_bitmap_clear(b_bitmap_word *map, unsigned long bit);
|
||||
BLUE_API bool b_bitmap_check(const b_bitmap_word *map, unsigned long bit);
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_bitmap)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_bitmap)
|
||||
|
||||
BLUE_API unsigned int b_bitmap_count_set(const b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API unsigned int b_bitmap_count_clear(const b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API b_type b_bitmap_get_type(void);
|
||||
|
||||
BLUE_API unsigned int b_bitmap_highest_set(const b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API unsigned int b_bitmap_highest_clear(const b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API unsigned int b_bitmap_lowest_set(const b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API unsigned int b_bitmap_lowest_clear(const b_bitmap_word *map, unsigned long nbits);
|
||||
BLUE_API b_bitmap *b_bitmap_create(size_t nr_bits);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
BLUE_API void b_bitmap_set_bit(b_bitmap *map, size_t bit);
|
||||
BLUE_API void b_bitmap_clear_bit(b_bitmap *map, size_t bit);
|
||||
BLUE_API void b_bitmap_set_range(b_bitmap *map, size_t first_bit, size_t nbits);
|
||||
BLUE_API void b_bitmap_clear_range(b_bitmap *map, size_t first_bit, size_t nbits);
|
||||
BLUE_API void b_bitmap_set_all(b_bitmap *map);
|
||||
BLUE_API void b_bitmap_clear_all(b_bitmap *map);
|
||||
|
||||
BLUE_API bool b_bitmap_check_bit(const b_bitmap *map, size_t bit);
|
||||
|
||||
BLUE_API size_t b_bitmap_count_set_bits(const b_bitmap *map);
|
||||
BLUE_API size_t b_bitmap_count_clear_bits(const b_bitmap *map);
|
||||
|
||||
BLUE_API size_t b_bitmap_highest_set_bit(const b_bitmap *map);
|
||||
BLUE_API size_t b_bitmap_highest_clear_bit(const b_bitmap *map);
|
||||
BLUE_API size_t b_bitmap_lowest_set_bit(const b_bitmap *map);
|
||||
BLUE_API size_t b_bitmap_lowest_clear_bit(const b_bitmap *map);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user