Home | History | Annotate | Download | only in src

Lines Matching refs:bitset

43 static	void			antlr3BitsetORInPlace	(pANTLR3_BITSET bitset, pANTLR3_BITSET bitset2);
44 static ANTLR3_UINT32 antlr3BitsetSize (pANTLR3_BITSET bitset);
45 static void antlr3BitsetAdd (pANTLR3_BITSET bitset, ANTLR3_INT32 bit);
47 static ANTLR3_BOOLEAN antlr3BitsetMember (pANTLR3_BITSET bitset, ANTLR3_UINT32 bit);
48 static ANTLR3_UINT32 antlr3BitsetNumBits (pANTLR3_BITSET bitset);
49 static void antlr3BitsetRemove (pANTLR3_BITSET bitset, ANTLR3_UINT32 bit);
50 static ANTLR3_BOOLEAN antlr3BitsetIsNil (pANTLR3_BITSET bitset);
51 static pANTLR3_INT32 antlr3BitsetToIntList (pANTLR3_BITSET bitset);
55 static void growToInclude (pANTLR3_BITSET bitset, ANTLR3_INT32 bit);
56 static void grow (pANTLR3_BITSET bitset, ANTLR3_INT32 newSize);
60 static void antlr3BitsetFree (pANTLR3_BITSET bitset);
63 antlr3BitsetFree(pANTLR3_BITSET bitset)
65 if (bitset->blist.bits != NULL)
67 ANTLR3_FREE(bitset->blist.bits);
68 bitset->blist.bits = NULL;
70 ANTLR3_FREE(bitset);
78 pANTLR3_BITSET bitset;
82 // Allocate memory for the bitset structure itself
84 bitset = (pANTLR3_BITSET) ANTLR3_MALLOC((size_t)sizeof(ANTLR3_BITSET));
86 if (bitset == NULL)
103 bitset->blist.bits = (pANTLR3_BITWORD) ANTLR3_MALLOC((size_t)(numelements * sizeof(ANTLR3_BITWORD)));
104 memset(bitset->blist.bits, 0, (size_t)(numelements * sizeof(ANTLR3_BITWORD)));
105 bitset->blist.length = numelements;
107 if (bitset->blist.bits == NULL)
109 ANTLR3_FREE(bitset);
113 antlr3BitsetSetAPI(bitset);
118 return bitset;
122 antlr3BitsetSetAPI(pANTLR3_BITSET bitset)
124 bitset->clone = antlr3BitsetClone;
125 bitset->bor = antlr3BitsetOR;
126 bitset->borInPlace = antlr3BitsetORInPlace;
127 bitset->size = antlr3BitsetSize;
128 bitset->add = antlr3BitsetAdd;
129 bitset->grow = grow;
130 bitset->equals = antlr3BitsetEquals;
131 bitset->isMember = antlr3BitsetMember;
132 bitset->numBits = antlr3BitsetNumBits;
133 bitset->remove = antlr3BitsetRemove;
134 bitset->isNilNode = antlr3BitsetIsNil;
135 bitset->toIntList = antlr3BitsetToIntList;
137 bitset->free = antlr3BitsetFree;
143 pANTLR3_BITSET bitset;
146 // Allocate memory for the bitset structure itself
148 bitset = (pANTLR3_BITSET) ANTLR3_MALLOC((size_t)sizeof(ANTLR3_BITSET));
150 if (bitset == NULL)
166 bitset->blist.length = numElements;
168 bitset->blist.bits = (pANTLR3_BITWORD)ANTLR3_MALLOC((size_t)(numElements * sizeof(ANTLR3_BITWORD)));
170 if (bitset->blist.bits == NULL)
172 ANTLR3_FREE(bitset);
176 ANTLR3_MEMCPY(bitset->blist.bits, blist->bits, (ANTLR3_UINT64)(numElements * sizeof(ANTLR3_BITWORD)));
180 return bitset;
186 pANTLR3_BITSET bitset;
188 // Allocate memory for the bitset structure itself
190 bitset = antlr3BitsetNew(ANTLR3_BITSET_BITS * inSet->blist.length);
192 if (bitset == NULL)
199 ANTLR3_MEMCPY(bitset->blist.bits, inSet->blist.bits, (ANTLR3_UINT64)(inSet->blist.length * sizeof(ANTLR3_BITWORD)));
203 return bitset;
210 pANTLR3_BITSET bitSet;
216 // so create a default bitset and then just add stuff
219 bitSet = antlr3BitsetNew(0);
225 bitSet->add(bitSet, (ANTLR3_UINT32)bit);
234 /// Creates a new bitset with at least one 64 bit bset of bits, but as
246 /// - pANTLR3_BITSET = antlrBitsetOf(-1); Create empty bitset
256 pANTLR3_BITSET bitset;
259 // Allocate memory for the bitset structure itself
261 // to include in the bitset, so we need at at least
267 bitset = antlr3BitsetNew(0);
269 if (bitset == NULL)
281 if (bitset->blist.length <= count)
283 bitset->grow(bitset, count+1);
286 bitset->blist.bits[count] = *((inBits->bits)+count);
291 // return the new bitset
293 return bitset;
298 /// Creates a new bitset with at least one element, but as
309 /// - pANTLR3_BITSET = antlrBitsetOf(-1); Create empty bitset
319 pANTLR3_BITSET bitset;
323 // Allocate memory for the bitset structure itself
325 // to include in the bitset, so we need at at least
331 bitset = antlr3BitsetNew(0);
333 if (bitset == NULL)
343 antlr3BitsetAdd(bitset, bit);
348 // return the new bitset
350 return bitset;
356 pANTLR3_BITSET bitset;
368 // Allocate memory for the newly ordered bitset structure itself.
370 bitset = antlr3BitsetClone(bitset1);
372 antlr3BitsetORInPlace(bitset, bitset2);
374 return bitset;
379 antlr3BitsetAdd(pANTLR3_BITSET bitset, ANTLR3_INT32 bit)
385 if (word >= bitset->blist.length)
387 growToInclude(bitset, bit);
390 bitset->blist.bits[word] |= bitMask(bit);
395 grow(pANTLR3_BITSET bitset, ANTLR3_INT32 newSize)
399 // Space for newly sized bitset - TODO: come back to this and use realloc?, it may
403 if (bitset->blist.bits != NULL)
407 ANTLR3_MEMCPY((void *)newBits, (const void *)bitset->blist.bits, (size_t)(bitset->blist.length * sizeof(ANTLR3_BITWORD)));
411 ANTLR3_FREE(bitset->blist.bits);
416 bitset->blist.bits = newBits;
417 bitset->blist.length = newSize;
421 growToInclude(pANTLR3_BITSET bitset, ANTLR3_INT32 bit)
426 bl = (bitset->blist.length << 1);
431 bitset->grow(bitset, bl);
435 bitset->grow(bitset, nw);
440 antlr3BitsetORInPlace(pANTLR3_BITSET bitset, pANTLR3_BITSET bitset2)
451 // First make sure that the target bitset is big enough
454 if (bitset->blist.length < bitset2->blist.length)
456 growToInclude(bitset, (bitset2->blist.length * sizeof(ANTLR3_BITWORD)));
461 if (bitset->blist.length < bitset2->blist.length)
463 minimum = bitset->blist.length;
472 bitset->blist.bits[i-1] |= bitset2->blist.bits[i-1];
483 antlr3BitsetSize(pANTLR3_BITSET bitset)
495 for (i = bitset->blist.length - 1; i>= 0; i--)
497 if (bitset->blist.bits[i] != 0)
501 if ((bitset->blist.bits[i] & (((ANTLR3_BITWORD)1) << bit)) != 0)
571 antlr3BitsetMember(pANTLR3_BITSET bitset, ANTLR3_UINT32 bit)
577 if (wordNo >= bitset->blist.length)
582 if ((bitset->blist.bits[wordNo] & bitMask(bit)) == 0)
593 antlr3BitsetRemove(pANTLR3_BITSET bitset, ANTLR3_UINT32 bit)
599 if (wordNo < bitset->blist.length)
601 bitset->blist.bits[wordNo] &= ~(bitMask(bit));
605 antlr3BitsetIsNil(pANTLR3_BITSET bitset)
609 for (i = bitset->blist.length -1; i>= 0; i--)
611 if (bitset->blist.bits[i] != 0)
633 antlr3BitsetNumBits(pANTLR3_BITSET bitset)
635 return bitset->blist.length << ANTLR3_BITSET_LOG_BITS;
639 * in this bitset. Used for error processing in the main as the bitset
646 antlr3BitsetToIntList (pANTLR3_BITSET bitset)
655 numInts = bitset->size(bitset) + 1;
656 numBits = bitset->numBits(bitset);
671 if (bitset->isMember(bitset, i) == ANTLR3_TRUE)