Mercurial > hg > Members > masakoha > testcode
annotate c/regexParser/bitVector.cc @ 138:ea2810db8d87 pairPro
remove warning and error
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 06 Dec 2015 15:54:05 +0900 (2015-12-06) |
parents | c292c67b3100 |
children | 84a2a5209d3a |
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(); |
138
ea2810db8d87
remove warning and error
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
137
diff
changeset
|
6 void bitSet(BitVectorPtr bi, int bitSetPosition); |
94
43b807f88961
implement bitvector (suspend)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
7 |
138
ea2810db8d87
remove warning and error
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
137
diff
changeset
|
8 BitVectorPtr createBitVector(NodePtr n) { |
ea2810db8d87
remove warning and error
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
137
diff
changeset
|
9 BitVectorPtr nextBvl = allocateBitVector(); |
ea2810db8d87
remove warning and error
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
137
diff
changeset
|
10 bitSet(nextBvl,n->nodeNumber); |
110 | 11 return nextBvl; |
12 } | |
13 | |
115
ca30f8334741
rename createRegexParser.cc to regexParser.cc
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
14 const BitVectorPtr allocateBitVector() { |
94
43b807f88961
implement bitvector (suspend)
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
15 BitVectorPtr bi = (BitVectorPtr)malloc(sizeof(BitVector)); |
137 | 16 bi->bitContainer = 0; |
110 | 17 return bi; |
18 } | |
19 | |
137 | 20 void bitSet(BitVectorPtr bi, int bitSetPosition) { |
117
166136236891
add header files
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
21 unsigned long tmp = 1 << (bitSetPosition % BITBLOCK); |
137 | 22 bi->bitContainer = bi->bitContainer | tmp; |
23 return; | |
86
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 |
1d7ca366b199
add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 void bitPrint(BitVectorPtr bi) { |
137 | 27 unsigned long vec = bi->bitContainer; |
28 for (int j = 0; j < BITBLOCK; j++) { | |
138
ea2810db8d87
remove warning and error
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
137
diff
changeset
|
29 putchar((vec & 1) ? '1':'0'); |
137 | 30 vec >>= 1; |
86
1d7ca366b199
add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 } |
137 | 32 printf("\n"); |
86
1d7ca366b199
add bitVector
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 } |