| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef BITMAPSET_H |
| #define BITMAPSET_H |
|
|
| #include "nodes/nodes.h" |
|
|
| |
| |
| |
| struct List; |
|
|
| |
| |
| |
| |
| |
| |
| |
| #if SIZEOF_VOID_P >= 8 |
|
|
| #define BITS_PER_BITMAPWORD 64 |
| typedef uint64 bitmapword; |
| typedef int64 signedbitmapword; |
|
|
| #else |
|
|
| #define BITS_PER_BITMAPWORD 32 |
| typedef uint32 bitmapword; |
| typedef int32 signedbitmapword; |
|
|
| #endif |
|
|
| typedef struct Bitmapset |
| { |
| pg_node_attr(custom_copy_equal, special_read_write, no_query_jumble) |
|
|
| NodeTag type; |
| int nwords; |
| bitmapword words[FLEXIBLE_ARRAY_MEMBER]; |
| } Bitmapset; |
|
|
|
|
| |
| typedef enum |
| { |
| BMS_EQUAL, |
| BMS_SUBSET1, |
| BMS_SUBSET2, |
| BMS_DIFFERENT, |
| } BMS_Comparison; |
|
|
| |
| typedef enum |
| { |
| BMS_EMPTY_SET, |
| BMS_SINGLETON, |
| BMS_MULTIPLE, |
| } BMS_Membership; |
|
|
| |
| #if BITS_PER_BITMAPWORD == 32 |
| #define bmw_leftmost_one_pos(w) pg_leftmost_one_pos32(w) |
| #define bmw_rightmost_one_pos(w) pg_rightmost_one_pos32(w) |
| #define bmw_popcount(w) pg_popcount32(w) |
| #elif BITS_PER_BITMAPWORD == 64 |
| #define bmw_leftmost_one_pos(w) pg_leftmost_one_pos64(w) |
| #define bmw_rightmost_one_pos(w) pg_rightmost_one_pos64(w) |
| #define bmw_popcount(w) pg_popcount64(w) |
| #else |
| #error "invalid BITS_PER_BITMAPWORD" |
| #endif |
|
|
|
|
| |
| |
| |
|
|
| extern Bitmapset *bms_copy(const Bitmapset *a); |
| extern bool bms_equal(const Bitmapset *a, const Bitmapset *b); |
| extern int bms_compare(const Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_make_singleton(int x); |
| extern void bms_free(Bitmapset *a); |
|
|
| extern Bitmapset *bms_union(const Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_intersect(const Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_difference(const Bitmapset *a, const Bitmapset *b); |
| extern bool bms_is_subset(const Bitmapset *a, const Bitmapset *b); |
| extern BMS_Comparison bms_subset_compare(const Bitmapset *a, const Bitmapset *b); |
| extern bool bms_is_member(int x, const Bitmapset *a); |
| extern int bms_member_index(Bitmapset *a, int x); |
| extern bool bms_overlap(const Bitmapset *a, const Bitmapset *b); |
| extern bool bms_overlap_list(const Bitmapset *a, const struct List *b); |
| extern bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b); |
| extern int bms_singleton_member(const Bitmapset *a); |
| extern bool bms_get_singleton_member(const Bitmapset *a, int *member); |
| extern int bms_num_members(const Bitmapset *a); |
|
|
| |
| extern BMS_Membership bms_membership(const Bitmapset *a); |
|
|
| |
| #define bms_is_empty(a) ((a) == NULL) |
|
|
| |
|
|
| extern Bitmapset *bms_add_member(Bitmapset *a, int x); |
| extern Bitmapset *bms_del_member(Bitmapset *a, int x); |
| extern Bitmapset *bms_add_members(Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_replace_members(Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_add_range(Bitmapset *a, int lower, int upper); |
| extern Bitmapset *bms_int_members(Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_del_members(Bitmapset *a, const Bitmapset *b); |
| extern Bitmapset *bms_join(Bitmapset *a, Bitmapset *b); |
|
|
| |
| extern int bms_next_member(const Bitmapset *a, int prevbit); |
| extern int bms_prev_member(const Bitmapset *a, int prevbit); |
|
|
| |
| extern uint32 bms_hash_value(const Bitmapset *a); |
| extern uint32 bitmap_hash(const void *key, Size keysize); |
| extern int bitmap_match(const void *key1, const void *key2, Size keysize); |
|
|
| #endif |
|
|