folly::select64

Returns the position of the k-th 1 in the 64-bit word x. k is 0-based, so k=0 returns the position of the first 1.

Synopses

Declared in <folly/compression/Select64.h>

Returns the position of the k-th 1 in the 64-bit word x. k is 0-based, so k=0 returns the position of the first 1.

template<class Instructions>
uint64_t
select64(
    uint64_t x,
    uint64_t k);
» more...
template<>
uint64_t
select64<Haswell>(
    uint64_t x,
    uint64_t k);
» more...

Return Value

The bit position of the k-th set bit in x.

Parameters

NameDescription
xThe 64-bit word to search.
kThe 0-based index of the set bit to locate.