annotate c/regexParser/bitVector.cc @ 137:c292c67b3100 pairPro

add generateTransitionList function
author masa
date Fri, 04 Dec 2015 20:32:09 +0900
parents 166136236891
children ea2810db8d87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdlib.h>
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <string.h>
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "bitVector.h"
115
ca30f8334741 rename createRegexParser.cc to regexParser.cc
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
5 const BitVectorPtr allocateBitVector();
94
43b807f88961 implement bitvector (suspend)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
6
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
7 BitVectorListPtr createBitVector(NodePtr n) {
110
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
8 BitVectorListPtr nextBvl = allocateBitVectorList();
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
9 nextBvl->bi = bitSet(nextBvl,n->nodeNumber);
110
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
10 return nextBvl;
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
11 }
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
12
115
ca30f8334741 rename createRegexParser.cc to regexParser.cc
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
13 const BitVectorPtr allocateBitVector() {
94
43b807f88961 implement bitvector (suspend)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 86
diff changeset
14 BitVectorPtr bi = (BitVectorPtr)malloc(sizeof(BitVector));
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
15 bi->bitContainer = 0;
110
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
16 return bi;
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
17 }
a3adc5c24e19 start branch
masa
parents: 108
diff changeset
18
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
19 void bitSet(BitVectorPtr bi, int bitSetPosition) {
117
166136236891 add header files
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
20 unsigned long tmp = 1 << (bitSetPosition % BITBLOCK);
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
21 bi->bitContainer = bi->bitContainer | tmp;
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
22 return;
86
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 void bitPrint(BitVectorPtr bi) {
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
26 unsigned long vec = bi->bitContainer;
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
27 for (int j = 0; j < BITBLOCK; j++) {
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
28 putchar((vec & 1)?'1:'0');
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
29 vec >>= 1;
86
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 }
137
c292c67b3100 add generateTransitionList function
masa
parents: 117
diff changeset
31 printf("\n");
86
1d7ca366b199 add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 }