Returns the (logical) position in the bm[] array, i, such that bm[i] is the offset-th set bit in the array. It is the inverse of pos_to_offset. get_pos() uses this function to find the index of an ne_iterator in the table. Bit-twiddling from http://hackersdelight.org/basics.pdf -----------------------------------------------------------------
| 1194 | // http://hackersdelight.org/basics.pdf |
| 1195 | // ----------------------------------------------------------------- |
| 1196 | static size_type offset_to_pos(group_bm_type bm, size_type offset) |
| 1197 | { |
| 1198 | for (; offset > 0; offset--) |
| 1199 | bm &= (bm-1); // remove right-most set bit |
| 1200 | |
| 1201 | // Clear all bits to the left of the rightmost bit (the &), |
| 1202 | // and then clear the rightmost bit but set all bits to the |
| 1203 | // right of it (the -1). |
| 1204 | // -------------------------------------------------------- |
| 1205 | bm = (bm & -bm) - 1; |
| 1206 | return static_cast<size_type>(spp_popcount(bm)); |
| 1207 | } |
| 1208 | |
| 1209 | #ifdef _MSC_VER |
| 1210 | #pragma warning(pop) |