Mercurial > hg > Applications > Grep
view c/regexParser/bitVector.cc @ 162:d7f762404113 pairPro
add TestCode
author | masa |
---|---|
date | Fri, 18 Dec 2015 19:31:13 +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"); }