Eneboo - Documentación para desarrolladores
|
00001 /*------------------------------------------------------------------------- 00002 * 00003 * bitmapset.h 00004 * PostgreSQL generic bitmap set package 00005 * 00006 * A bitmap set can represent any set of nonnegative integers, although 00007 * it is mainly intended for sets where the maximum value is not large, 00008 * say at most a few hundred. By convention, a NULL pointer is always 00009 * accepted by all operations to represent the empty set. (But beware 00010 * that this is not the only representation of the empty set. Use 00011 * bms_is_empty() in preference to testing for NULL.) 00012 * 00013 * 00014 * Copyright (c) 2003-2005, PostgreSQL Global Development Group 00015 * 00016 * $PostgreSQL: pgsql/src/include/nodes/bitmapset.h,v 1.7 2005/06/08 23:02:05 tgl Exp $ 00017 * 00018 *------------------------------------------------------------------------- 00019 */ 00020 #ifndef BITMAPSET_H 00021 #define BITMAPSET_H 00022 00023 /* 00024 * Data representation 00025 */ 00026 00027 /* The unit size can be adjusted by changing these three declarations: */ 00028 #define BITS_PER_BITMAPWORD 32 00029 typedef uint32 bitmapword; /* must be an unsigned type */ 00030 typedef int32 signedbitmapword; /* must be the matching signed type */ 00031 00032 typedef struct Bitmapset 00033 { 00034 int nwords; /* number of words in array */ 00035 bitmapword words[1]; /* really [nwords] */ 00036 } Bitmapset; /* VARIABLE LENGTH STRUCT */ 00037 00038 00039 /* result of bms_membership */ 00040 typedef enum 00041 { 00042 BMS_EMPTY_SET, /* 0 members */ 00043 BMS_SINGLETON, /* 1 member */ 00044 BMS_MULTIPLE /* >1 member */ 00045 } BMS_Membership; 00046 00047 00048 /* 00049 * function prototypes in nodes/bitmapset.c 00050 */ 00051 00052 extern Bitmapset *bms_copy(const Bitmapset *a); 00053 extern bool bms_equal(const Bitmapset *a, const Bitmapset *b); 00054 extern Bitmapset *bms_make_singleton(int x); 00055 extern void bms_free(Bitmapset *a); 00056 00057 extern Bitmapset *bms_union(const Bitmapset *a, const Bitmapset *b); 00058 extern Bitmapset *bms_intersect(const Bitmapset *a, const Bitmapset *b); 00059 extern Bitmapset *bms_difference(const Bitmapset *a, const Bitmapset *b); 00060 extern bool bms_is_subset(const Bitmapset *a, const Bitmapset *b); 00061 extern bool bms_is_member(int x, const Bitmapset *a); 00062 extern bool bms_overlap(const Bitmapset *a, const Bitmapset *b); 00063 extern bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b); 00064 extern int bms_singleton_member(const Bitmapset *a); 00065 extern int bms_num_members(const Bitmapset *a); 00066 00067 /* optimized tests when we don't need to know exact membership count: */ 00068 extern BMS_Membership bms_membership(const Bitmapset *a); 00069 extern bool bms_is_empty(const Bitmapset *a); 00070 00071 /* these routines recycle (modify or free) their non-const inputs: */ 00072 00073 extern Bitmapset *bms_add_member(Bitmapset *a, int x); 00074 extern Bitmapset *bms_del_member(Bitmapset *a, int x); 00075 extern Bitmapset *bms_add_members(Bitmapset *a, const Bitmapset *b); 00076 extern Bitmapset *bms_int_members(Bitmapset *a, const Bitmapset *b); 00077 extern Bitmapset *bms_del_members(Bitmapset *a, const Bitmapset *b); 00078 extern Bitmapset *bms_join(Bitmapset *a, Bitmapset *b); 00079 00080 /* support for iterating through the integer elements of a set: */ 00081 extern int bms_first_member(Bitmapset *a); 00082 00083 /* support for hashtables using Bitmapsets as keys: */ 00084 extern uint32 bms_hash_value(const Bitmapset *a); 00085 00086 #endif /* BITMAPSET_H */