Mercurial > hg > Members > masakoha > testcode
diff regexParser/bitVector.cc @ 182:dbe004d03ef0 pairPro
implement stateAllocate()
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 24 Dec 2015 19:14:49 +0900 |
parents | 3bf2c6d6d53e |
children | ef798db705e9 |
line wrap: on
line diff
--- a/regexParser/bitVector.cc Thu Dec 24 18:00:55 2015 +0900 +++ b/regexParser/bitVector.cc Thu Dec 24 19:14:49 2015 +0900 @@ -3,26 +3,20 @@ #include <string.h> #include "bitVector.h" -BitVectorPtr createBitVector(NodePtr n) { - BitVectorPtr bi = allocateBitVector(); - bitSet(bi,n->nodeNumber); - return bi; +BitVector createBitvector(int state) { + unsigned long tmp = 1 << bitSetPosition; + BitVector bi1 = (struct BitVector){.bitContainer = tmp}; + return bi1; } -const BitVectorPtr allocateBitVector() { - BitVectorPtr bi = (BitVectorPtr)malloc(sizeof(BitVector)); - bi->bitContainer = 0; - return bi; +BitVector bitSet(BitVector bi, int bitSetPosition) { + unsigned long tmp = 1 << bitSetPosition; + BitVector bi1 = (struct BitVector){.bitContainer = bi.bitContainer | tmp}; + return bi1; } -void bitSet(BitVectorPtr bi, int bitSetPosition) { - unsigned long tmp = 1 << (bitSetPosition % BITBLOCK); - bi->bitContainer = bi->bitContainer | tmp; - return; -} - -void bitPrint(BitVectorPtr bi) { - unsigned long vec = bi->bitContainer; +void bitPrint(BitVector bi) { + unsigned long vec = bi.bitContainer; for (int j = 0; j < BITBLOCK; j++) { putchar((vec & 1) ? '1':'0'); vec >>= 1;