Mercurial > hg > Members > masakoha > testcode
view c/regexParser/bitVector.cc @ 144:d8a4922eceae pairPro
remove some errors (not working)
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2015 17:14:33 +0900 |
parents | 84a2a5209d3a |
children |
line wrap: on
line source
#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"); }