bitmap_ord_to_pos — find position of n-th set bit in bitmap
unsigned intbitmap_ord_to_pos( | const unsigned long *buf, |
| unsigned intord, | |
unsigned intnbits); |
const unsigned long * bufpointer to bitmap
unsigned int ordordinal bit position (n-th set bit, n >= 0)
unsigned int nbits number of valid bit positions inbuf
Map the ordinal offset of bitord inbuf to its position inbuf. Value oford should be in range 0 <=ord < weight(buf). Iford >= weight(buf), returnsnbits.
If for example, just bits 4 through 7 are set inbuf, thenord values 0 through 3 will get mapped to 4 through 7, respectively, and all otherord values returnsnbits. Whenord value 3 gets mapped to (returns)pos value 7 in this example, that means that the 3rd set bit (starting with 0th) is at position 7 inbuf.
The bit positions 0 throughnbits-1 are valid positions inbuf.