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