Changeset 2869
- Timestamp:
- 2001-11-28T15:14:56+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/phind/generate/check.h
r2867 r2869 15 15 16 16 #include "suffix.h" 17 #include <inttypes.h> 17 18 18 19 // The suffixCheck array 19 typedef u nsigned charcheck;20 typedef uint8_t check; 20 21 check *suffixCheck; 21 22 … … 24 25 25 26 // Some useful bitmask constants 26 const check ALLBITS = 255; 27 const check LEFTMOSTBIT = (ALLBITS << 7); 28 const check LEFTMOSTBITS[] = {0, 29 (ALLBITS << 7), (ALLBITS << 6), (ALLBITS << 5), (ALLBITS << 4), 30 (ALLBITS << 3), (ALLBITS << 2), (ALLBITS << 1), ALLBITS}; 31 //const check LEFTMOSTBIT = 128; 32 //const check LEFTMOSTBITS[] = {0, 128, 192, 224, 240, 248, 252, 254, 255}; 27 const check ALLBITS = 255; 28 const check LEFTMOSTBIT = static_cast<check>(ALLBITS << 7); 29 const check LEFTMOSTBITS[] = {static_cast<check>(ALLBITS << 8), 30 static_cast<check>(ALLBITS << 7), 31 static_cast<check>(ALLBITS << 6), 32 static_cast<check>(ALLBITS << 5), 33 static_cast<check>(ALLBITS << 4), 34 static_cast<check>(ALLBITS << 3), 35 static_cast<check>(ALLBITS << 2), 36 static_cast<check>(ALLBITS << 1), 37 static_cast<check>(ALLBITS << 0)}; 33 38 34 39 … … 54 59 55 60 // Get the value of a particular bit in suffixCheck 56 inline int getSuffixCheck(cellindex suff)61 inline int getSuffixCheck(cellindex position) 57 62 { 58 cellindex cell = suff>> 3;59 check remainder = suff& 0x07; // the last 3 bits63 cellindex cell = position >> 3; 64 check remainder = position & 0x07; // the last 3 bits 60 65 if (suffixCheck[cell] & (LEFTMOSTBIT >> remainder)) { 61 66 return 1; … … 69 74 { 70 75 cellindex cell = suff >> 3; 71 check remainder = suff & 0x07 ; // the last 3 bits76 check remainder = suff & 0x07u; // the last 3 bits 72 77 suffixCheck[cell] |= (LEFTMOSTBIT >> remainder); 73 78 } 74 75 76 // Set the value of a range of bits in suffixCheck to 177 void setSuffixCheck(cellindex first, cellindex last)78 {79 for (cellcount i = first; i <= last; ++i)80 setSuffixCheck(i);81 }82 79 83 80 … … 92 89 93 90 94 inline void setSuffixCheck _new(cellindex first, cellindex last)91 inline void setSuffixCheck(cellindex first, cellindex last) 95 92 { 96 93 // If only one bit is set, use simpler function 97 // We should be able to remove this case.98 94 if (first == last) { 99 95 setSuffixCheck(first); … … 107 103 // If all the values are in the same cell, set them 108 104 if (first_cell == last_cell) { 109 setCellBits(first_cell, (first & 0x07 ), (last & 0x07));105 setCellBits(first_cell, (first & 0x07u), (last & 0x07u)); 110 106 return; 111 107 } 112 108 113 109 // Set the bits in the first and last cells 114 setCellBits(first_cell, (first & 0x07 ), 7);115 setCellBits(last_cell, 0, (last & 0x07 ));110 setCellBits(first_cell, (first & 0x07u), 7); 111 setCellBits(last_cell, 0, (last & 0x07u)); 116 112 117 113 // Set the bits in the intermediate cells … … 129 125 cout << "cell " << i << " \t"; 130 126 cout << "(" << (i * 8) << "-" << (i * 8 + 7) << ") \t"; 131 for (cellindex j = 0; j < 8; ++j) {127 for (cellindex j = 0; j < 8; ++j) 132 128 cout << getSuffixCheck(i * 8 + j); 133 // cout << " (" << (i * 8 + j) << ") ";134 }135 129 cout << " (" << (unsigned int) suffixCheck[i] << ")\n"; 136 130 } 137 131 } 138 132 133 // To test, insert at start of main: 139 134 140 // To test, put this at the start of main 135 // allocateSuffixCheck(300); 136 // clearSuffixCheck(); 141 137 142 // allocateSuffixCheck(300); 143 // clearSuffixCheck(); 144 // setSuffixCheck(20); 145 // setSuffixCheck(35,50); 146 // setSuffixCheck(68,150); 147 // setSuffixCheck(170,174); 148 // setSuffixCheck(220,230); 149 // setSuffixCheck(247); 150 // setSuffixCheck(256); 151 // printSuffixCheck(); 152 // exit(0); 138 // setSuffixCheck(20); 139 // setSuffixCheck(35,50); 140 // setSuffixCheck(68,150); 141 // setSuffixCheck(170,174); 142 // setSuffixCheck(220,230); 143 // setSuffixCheck(247); 144 // setSuffixCheck(256); 153 145 146 // printSuffixCheck(); 147 // exit(0); 148
Note:
See TracChangeset
for help on using the changeset viewer.