| 147 | } |
| 148 | |
| 149 | int MinorKey::getAbsoluteColumnIndex(const int i) const |
| 150 | { |
| 151 | /* This method is to return the absolute (0-based) index of the i-th |
| 152 | column encoded in \a this. |
| 153 | Example: bit-pattern of columns: "10010001101", i = 3: |
| 154 | This should yield the 0-based absolute index of the 3-rd bit |
| 155 | (counted from the right), i.e. 7. */ |
| 156 | |
| 157 | int matchedBits = -1; /* counter for matched bits; this needs to reach i, |
| 158 | then we're done */ |
| 159 | for (int block = 0; block < getNumberOfColumnBlocks(); block ++) |
| 160 | { |
| 161 | /* start with lowest bits, i.e. in block No. 0 */ |
| 162 | /* the bits in this block of 32 bits: */ |
| 163 | unsigned int blockBits = getColumnKey(block); |
| 164 | unsigned int shiftedBit = 1; |
| 165 | int exponent = 0; |
| 166 | /* The invariant "shiftedBit = 2^exponent" will hold throughout the |
| 167 | entire while loop. */ |
| 168 | while (exponent < 32) |
| 169 | { |
| 170 | if (shiftedBit & blockBits) matchedBits++; |
| 171 | if (matchedBits == i) return exponent + (32 * block); |
| 172 | shiftedBit = shiftedBit << 1; |
| 173 | exponent++; |
| 174 | } |
| 175 | } |
| 176 | /* We should never reach this line of code. */ |
| 177 | assume(false); |
| 178 | return -1; |
| 179 | } |
| 180 | |
| 181 | void MinorKey::getAbsoluteRowIndices(int* const target) const |
| 182 | { |
no outgoing calls
no test coverage detected