Mercurial > hg > Members > masakoha > testcode
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 |
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 | 7 BitVectorListPtr createBitVector(NodePtr n) { |
110 | 8 BitVectorListPtr nextBvl = allocateBitVectorList(); |
137 | 9 nextBvl->bi = bitSet(nextBvl,n->nodeNumber); |
110 | 10 return nextBvl; |
11 } | |
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 | 15 bi->bitContainer = 0; |
110 | 16 return bi; |
17 } | |
18 | |
137 | 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 | 21 bi->bitContainer = bi->bitContainer | tmp; |
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 | 26 unsigned long vec = bi->bitContainer; |
27 for (int j = 0; j < BITBLOCK; j++) { | |
28 putchar((vec & 1)?'1:'0'); | |
29 vec >>= 1; | |
86
1d7ca366b199
add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 } |
137 | 31 printf("\n"); |
86
1d7ca366b199
add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 } |