35 #define NBYTES(n) ((n) * sizeof(BITSET_CARRIER)) 36 #define NELEMS(n) ((n) * _WORDSIZE) 38 #define bitset_malloc(env, size) malloc(size) 39 #define bitset_free(ptr) free_and_init(ptr) 66 #if defined (CUBRID_DEBUG) 75 fprintf (fp,
"Set statistics no longer collected\n");
103 memcpy (words, dst->setp,
NBYTES (dst->nwords));
104 memset (words + dst->nwords, 0,
NBYTES (nwords - dst->nwords));
105 dst->nwords = nwords;
106 if (dst->setp != dst->set.word)
122 if (dst->nwords < src->nwords)
127 memcpy (dst->setp, src->setp,
NBYTES (src->nwords));
128 memset (dst->setp + src->nwords, 0,
NBYTES (dst->nwords - src->nwords));
143 if (n >= dst->nwords)
148 dst->setp[n] |= (1L <<
_BIT (x));
165 dst->setp[n] &= ~(1L <<
_BIT (x));
180 if (dst->nwords < src->nwords)
185 nwords = src->nwords;
189 dst->setp[nwords] |= src->setp[nwords];
204 nwords = dst->nwords;
205 while (nwords > src->nwords)
208 dst->setp[nwords] = 0;
213 dst->setp[nwords] &= src->setp[nwords];
228 nwords = MIN (dst->nwords, src->nwords);
232 dst->setp[nwords] &= ~src->setp[nwords];
236 #if defined (ENABLE_UNUSED_FUNCTION) 243 bitset_invert (
BITSET * dst)
247 nwords = dst->nwords;
251 dst->setp[nwords] = ~dst->setp[nwords];
268 while (nwords > r->nwords)
279 if ((r->setp[nwords] & s->setp[nwords]) != s->setp[nwords])
299 nwords = MIN (r->nwords, s->nwords);
303 if (r->setp[nwords] & s->setp[nwords])
346 if (r->nwords < s->nwords)
349 while (nwords > r->nwords)
358 else if (r->nwords > s->nwords)
361 while (nwords > s->nwords)
378 if (r->setp[nwords] != s->setp[nwords])
404 word = s->setp[nwords];
407 card +=
nbits[word & 0xf];
415 #if defined (ENABLE_UNUSED_FUNCTION) 423 bitset_position (
const BITSET * s,
int x)
434 for (i = 0, m =
_WORD (x); i < m; i++)
436 for (word = s->setp[i]; word; word >>= 4)
438 pos +=
nbits[word & 0xf];
442 mask = (1L << x) - 1;
443 for (word = s->setp[m] & mask; word; word >>= 4)
445 pos +=
nbits[word & 0xf];
491 nwords = si->
set->nwords;
494 for (word = si->
set->setp[m] >>
_BIT (current); word; current++, word >>= 1)
498 si->
next = current + 1;
531 (void) fprintf (fp,
"empty");
541 (void) fprintf (fp,
"%d", i);
544 (void) fprintf (fp,
" %d", i);
560 s->setp = s->set.word;
573 if (s->setp != s->set.word)
unsigned int BITSET_CARRIER
int bitset_is_equivalent(const BITSET *r, const BITSET *s)
int bitset_intersects(const BITSET *r, const BITSET *s)
int bitset_iterate(const BITSET *s, BITSET_ITERATOR *si)
int bitset_is_empty(const BITSET *s)
void bitset_difference(BITSET *dst, const BITSET *src)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int bitset_subset(const BITSET *r, const BITSET *s)
void bitset_print(const BITSET *s, FILE *fp)
void bitset_delset(BITSET *s)
void bitset_assign(BITSET *dst, const BITSET *src)
void bitset_union(BITSET *dst, const BITSET *src)
#define ER_OUT_OF_VIRTUAL_MEMORY
static BITSET_CARRIER empty_set_words[NWORDS]
void bitset_intersect(BITSET *dst, const BITSET *src)
int bitset_next_member(BITSET_ITERATOR *si)
void bitset_remove(BITSET *dst, int x)
void bitset_extend(BITSET *dst, int nwords)
#define BITSET_MEMBER(s, x)
static const char nbits[]
void bitset_init(BITSET *s, QO_ENV *env)
int bitset_cardinality(const BITSET *s)
int bitset_first_member(const BITSET *s)
void bitset_add(BITSET *dst, int x)