|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
位操作类与函数的实现 更多...
类 | |
| struct | bit_reference |
| 位引用类 更多... | |
| struct | bitmap_iterator< IsConst, BitMap > |
| 位图迭代器 更多... | |
| class | bitmap |
| 位图容器 更多... | |
| class | bitset< N > |
| 固定大小的位集 更多... | |
函数 | |
| constexpr int | popcount32 (const uint32_t x) noexcept |
| 计算32位整数中1的个数 | |
| NEFORCE_CONSTEXPR14 int | clz32 (uint32_t x) noexcept |
| 计算32位整数前导零的个数 | |
| constexpr int | popcount (const uintptr_t x) noexcept |
| 计算整数中1的个数 | |
| constexpr int | countl_zero (const uintptr_t x) noexcept |
| 计算整数前导零的个数 | |
| constexpr int | countl_one (const uintptr_t x) noexcept |
| 计算整数前导1的个数 | |
| constexpr int | countr_zero (const uintptr_t x) noexcept |
| 计算整数尾随零的个数 | |
| constexpr int | countr_one (const uintptr_t x) noexcept |
| 计算整数尾随1的个数 | |
| constexpr int | lowest_set_bit_pos (const intptr_t x) noexcept |
| 获取最低设置位的位置,从0开始 | |
| NEFORCE_CONSTEXPR14 int | highest_set_bit_pos (const intptr_t x) noexcept |
| 获取最高设置位的位置 | |
| NEFORCE_CONSTEXPR14 bool | parity32 (uint32_t x) noexcept |
| 计算32位整数的奇偶性 | |
| constexpr bool | parity (const uintptr_t x) noexcept |
| 计算整数的奇偶性 | |
| constexpr int | bit_width (const uintptr_t x) noexcept |
| 计算表示整数所需的最小位宽 | |
| constexpr uintptr_t | bit_floor (const uintptr_t x) noexcept |
| 获取不大于x的最大2的幂 | |
| NEFORCE_CONSTEXPR14 uint64_t | bit_ceil (const uintptr_t x) noexcept |
| 获取不小于x的最小2的幂 | |
| constexpr bool | has_single_bit (const uintptr_t x) noexcept |
| 检查整数是否为2的幂 | |
| NEFORCE_CONSTEXPR14 uint32_t | rotate_l32 (const uint32_t x, const int s) noexcept |
| 32位整数循环左移 | |
| NEFORCE_CONSTEXPR14 uint32_t | rotate_r32 (const uint32_t x, const int s) noexcept |
| 32位整数循环右移 | |
| NEFORCE_CONSTEXPR14 int | rotate_l (const uintptr_t x, const int s) noexcept |
| 整数循环左移 | |
| NEFORCE_CONSTEXPR14 int | rotate_r (const uintptr_t x, const int s) noexcept |
| 整数循环右移 | |
| constexpr uintptr_t | bit_extract (const uintptr_t x, const int pos, const int len) noexcept |
| 从整数中提取指定位段 | |
| NEFORCE_CONSTEXPR14 uintptr_t | bit_insert (const uintptr_t x, const uintptr_t bits, const int pos, const int len) noexcept |
| 向整数中插入指定位段 | |
| NEFORCE_CONSTEXPR14 uint32_t | reverse_bits32 (uint32_t x) noexcept |
| 反转32位整数的位顺序 | |
| constexpr uintptr_t | reverse_bits (const uintptr_t x) noexcept |
| 反转整数的位顺序 | |
| constexpr uintptr_t | mask_from_to (const int from, const int to) noexcept |
| 生成从from到to的位掩码 | |
变量 | |
| NEFORCE_INLINE17 constexpr uint32_t | BITMAP_WORD_SIZE = 8 * sizeof(uint32_t) |
| 每个字的位数 | |
| NEFORCE_INLINE17 constexpr byte_t | POPCOUNT_TABLE [256] |
| popcount查找表 | |
位操作类与函数的实现
|
constexprnoexcept |
|
noexcept |
计算32位整数前导零的个数
| x | 32位无符号整数 |
使用二分查找法优化前导零计数。
被这些函数引用 countl_zero() , 以及 highest_set_bit_pos().
|
constexprnoexcept |
|
constexprnoexcept |
计算整数前导零的个数
| x | 无符号整数 |
根据平台位数调用相应的clz函数。
引用了 clz32().
被这些函数引用 bit_width() , 以及 countl_one().
|
constexprnoexcept |
|
constexprnoexcept |
计算整数尾随零的个数
| x | 无符号整数 |
使用位运算技巧得到最低有效位的掩码。
引用了 popcount().
被这些函数引用 countr_one() , 以及 lowest_set_bit_pos().
|
constexprnoexcept |
|
noexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
noexcept |
|
constexprnoexcept |
计算整数中1的个数
| x | 无符号整数 |
根据平台位数调用相应的popcount函数。
引用了 popcount32().
被这些函数引用 bitset< N >::count() , 以及 countr_zero().
|
constexprnoexcept |
|
noexcept |
|
noexcept |
|
constexpr |
popcount查找表
预计算的popcount表,用于快速计算字节中1的个数。 包含0-255所有可能字节值的popcount值。