Mercurial > hg > Members > masakoha > testcode
diff regexParser/bitVector.cc @ 167:3bf2c6d6d53e pairPro
move regexparser dir
author | masa |
---|---|
date | Sat, 19 Dec 2015 15:38:45 +0900 |
parents | c/regexParser/bitVector.cc@84a2a5209d3a |
children | dbe004d03ef0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regexParser/bitVector.cc Sat Dec 19 15:38:45 2015 +0900 @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "bitVector.h" + +BitVectorPtr createBitVector(NodePtr n) { + BitVectorPtr bi = allocateBitVector(); + bitSet(bi,n->nodeNumber); + return bi; +} + +const BitVectorPtr allocateBitVector() { + BitVectorPtr bi = (BitVectorPtr)malloc(sizeof(BitVector)); + bi->bitContainer = 0; + return bi; +} + +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; + for (int j = 0; j < BITBLOCK; j++) { + putchar((vec & 1) ? '1':'0'); + vec >>= 1; + } + printf("\n"); +}