Mercurial > hg > Applications > Grep
comparison c/regexParser/bitVector.cc @ 115:ca30f8334741 pairPro
rename createRegexParser.cc to regexParser.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Nov 2015 14:38:26 +0900 |
parents | a3adc5c24e19 |
children | 66c633575b53 |
comparison
equal
deleted
inserted
replaced
114:c82e7a7ef8d9 | 115:ca30f8334741 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <string.h> | 3 #include <string.h> |
4 #include "bitVector.h" | 4 #include "bitVector.h" |
5 #include "regexParser.h" | |
5 | 6 |
6 void bitPrint(BitVectorPtr bi); | 7 extern BitVectorListPtr allocateBitVectorList(); |
8 BitVectorListPtr createBitVector(NodePtr,BitVectorListPtr); | |
9 const BitVectorPtr allocateBitVector(); | |
10 BitVectorPtr bitSet(int); | |
11 void bitPrint(BitVectorPtr); | |
7 | 12 |
8 int bitBlock = sizeof(unsigned long) * 8; | 13 int bitBlock = sizeof(unsigned long) * 8; |
9 | 14 |
10 BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { | 15 BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { |
11 BitVectorListPtr nextBvl = allocateBitVectorList(); | 16 BitVectorListPtr nextBvl = allocateBitVectorList(); |
12 nextBvl->bi = bitSet(n->nodeNumber); | 17 nextBvl->bi = bitSet(n->nodeNumber); |
13 nextBvl->initBvl = initBvl; | |
14 return nextBvl; | 18 return nextBvl; |
15 } | 19 } |
16 | 20 |
17 BitVectorPtr createBitVector(int bitSetPosition) { | 21 const BitVectorPtr allocateBitVector() { |
18 | 22 |
19 BitVectorPtr bi = (BitVectorPtr)malloc(sizeof(BitVector)); | 23 BitVectorPtr bi = (BitVectorPtr)malloc(sizeof(BitVector)); |
20 if (bi == NULL) { | 24 if (bi == NULL) { |
21 fprintf(stderr, "Failed to allocate memory.\n"); | 25 fprintf(stderr, "Failed to allocate memory.\n"); |
22 exit(-1); | 26 exit(-1); |
33 } | 37 } |
34 | 38 |
35 return bi; | 39 return bi; |
36 } | 40 } |
37 | 41 |
38 BitVectorPtr bitSet(BitVectorPtr bi, int bitSetPosition) { | 42 BitVectorPtr bitSet(int bitSetPosition) { |
43 | |
44 BitVectorPtr bi = allocateBitVector(); | |
39 | 45 |
40 bi->arrayNum = (bitSetPosition + bitBlock - 1) / bitBlock; | 46 bi->arrayNum = (bitSetPosition + bitBlock - 1) / bitBlock; |
41 | 47 |
42 int arrayPosition = bitSetPosition / bitBlock; | 48 int arrayPosition = bitSetPosition / bitBlock; |
43 | 49 |