|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
固定大小的位集 更多...
#include <bitset.hpp>
类 | |
| class | reference |
| 位引用类,用于返回可修改的引用 更多... | |
Public 成员函数 | |
| constexpr | bitset () noexcept |
| 默认构造函数,所有位初始化为0 | |
| constexpr | bitset (const block_type value) noexcept |
| 整数初始化 | |
| constexpr | bitset (const string_view str, const char zero='0', const char one='1') |
| 用字符串初始化bitset | |
| constexpr | bitset (const string &str, const char zero='0', const char one='1') |
| string初始化 | |
| constexpr | bitset (const char *str, const char zero='0', const char one='1') |
| C风格字符串初始化 | |
| constexpr bitset & | set () noexcept |
| 将所有位设置为1 | |
| constexpr bitset & | set (const size_t pos, const bool value=true) noexcept |
| 将指定位置的位设置为指定值 | |
| constexpr bitset & | reset () noexcept |
| 将所有位重置为0 | |
| constexpr bitset & | reset (const size_t pos) noexcept |
| 将指定位置的位重置为0 | |
| constexpr bitset & | flip () noexcept |
| 翻转所有位 | |
| constexpr bitset & | flip (const size_t pos) noexcept |
| 翻转指定位置的位 | |
| NEFORCE_NODISCARD constexpr bool | operator[] (const size_t pos) const noexcept |
| 常量下标访问 | |
| NEFORCE_NODISCARD constexpr reference | operator[] (size_t pos) noexcept |
| 非常量下标访问 | |
| NEFORCE_NODISCARD NEFORCE_ALWAYS_INLINE constexpr size_t | size () const noexcept |
| 获取位数 | |
| NEFORCE_NODISCARD NEFORCE_ALWAYS_INLINE constexpr bool | empty () const noexcept |
| 检查是否为空 | |
| NEFORCE_NODISCARD constexpr bool | test (const size_t position) const noexcept |
| 测试指定位置的位 | |
| NEFORCE_NODISCARD constexpr bitset & | operator&= (const bitset &other) noexcept |
| 按位与赋值 | |
| NEFORCE_NODISCARD constexpr bitset & | operator|= (const bitset &other) noexcept |
| 按位或赋值 | |
| NEFORCE_NODISCARD constexpr bitset & | operator^= (const bitset &other) noexcept |
| 按位异或赋值 | |
| NEFORCE_NODISCARD constexpr bitset | operator~ () const noexcept |
| 按位取反 | |
| NEFORCE_NODISCARD constexpr bitset & | operator<<= (const uint32_t pos) noexcept |
| 左移赋值 | |
| NEFORCE_NODISCARD constexpr bitset & | operator>>= (const uint32_t pos) noexcept |
| 右移赋值 | |
| NEFORCE_NODISCARD constexpr size_t | count () const noexcept |
| 统计值为1的位的数量 | |
| NEFORCE_NODISCARD constexpr bool | all () const noexcept |
| 检查所有位是否都为1 | |
| NEFORCE_NODISCARD constexpr bool | any () const noexcept |
| 检查是否存在值为1的位 | |
| NEFORCE_NODISCARD constexpr bool | none () const noexcept |
| 检查是否所有位都是0 | |
| NEFORCE_NODISCARD constexpr unsigned long | to_ulong () const noexcept |
| 转换为unsigned long | |
| NEFORCE_NODISCARD constexpr unsigned long long | to_ullong () const noexcept |
| 转换为unsigned long long | |
| NEFORCE_NODISCARD constexpr bool | operator== (const bitset &other) const noexcept |
| 相等比较操作符 | |
| NEFORCE_NODISCARD constexpr bool | operator< (const bitset &other) const noexcept |
| 小于比较操作符(按字典序) | |
| NEFORCE_NODISCARD constexpr size_t | to_hash () const noexcept |
| 计算哈希值 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string | to_string (const char zero, const char one) const |
| 转换为字符串 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string | to_string () const |
| 转换为字符串(默认使用'0'和'1') | |
| constexpr void | swap (bitset &other) noexcept |
| 交换两个bitset的内容 | |
| Public 成员函数 继承自 icomparable< bitset< N > > | |
| NEFORCE_NODISCARD constexpr bool | operator== (const bitset< N > &rhs) const noexcept(noexcept(derived()==rhs)) |
| 相等比较运算符 | |
| NEFORCE_NODISCARD constexpr bool | operator!= (const bitset< N > &rhs) const noexcept(noexcept(!(*this==rhs))) |
| 不等比较运算符 | |
| NEFORCE_NODISCARD constexpr bool | operator< (const bitset< N > &rhs) const noexcept(noexcept(derived()< rhs)) |
| 小于比较运算符 | |
| NEFORCE_NODISCARD constexpr bool | operator> (const bitset< N > &rhs) const noexcept(noexcept(rhs< derived())) |
| 大于比较运算符 | |
| NEFORCE_NODISCARD constexpr bool | operator<= (const bitset< N > &rhs) const noexcept(noexcept(!(derived() > rhs))) |
| 小于等于比较运算符 | |
| NEFORCE_NODISCARD constexpr bool | operator>= (const bitset< N > &rhs) const noexcept(noexcept(!(derived()< rhs))) |
| 大于等于比较运算符 | |
| Public 成员函数 继承自 ihashable< bitset< N > > | |
| NEFORCE_NODISCARD constexpr size_t | to_hash () const noexcept(noexcept(derived().to_hash())) |
| 获取对象的哈希值 | |
| Public 成员函数 继承自 ibinary< bitset< N > > | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 bitset< N > | operator& (const bitset< N > &other) const noexcept(noexcept(const_cast< bitset< N > & >(derived()).operator&=(other))) |
| 按位与运算符 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 bitset< N > | operator| (const bitset< N > &other) const noexcept(noexcept(const_cast< bitset< N > & >(derived()).operator|=(other))) |
| 按位或运算符 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 bitset< N > | operator^ (const bitset< N > &other) const noexcept(noexcept(const_cast< bitset< N > & >(derived()).operator^=(other))) |
| 按位异或运算符 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 bitset< N > | operator~ () const noexcept(noexcept(derived().operator~())) |
| 按位取反运算符 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 bitset< N > | operator<< (const uint32_t shift) const |
| 左移运算符 | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 bitset< N > | operator>> (const uint32_t shift) const |
| 右移运算符 | |
| NEFORCE_CONSTEXPR14 bitset< N > & | operator&= (const bitset< N > &other) noexcept(noexcept(derived().operator&=(other))) |
| 按位与赋值运算符 | |
| NEFORCE_CONSTEXPR14 bitset< N > & | operator|= (const bitset< N > &other) noexcept(noexcept(derived().operator|=(other))) |
| 按位或赋值运算符 | |
| NEFORCE_CONSTEXPR14 bitset< N > & | operator^= (const bitset< N > &other) noexcept(noexcept(derived().operator^=(other))) |
| 按位异或赋值运算符 | |
| NEFORCE_CONSTEXPR14 bitset< N > & | operator<<= (const uint32_t shift) |
| 左移赋值运算符 | |
| NEFORCE_CONSTEXPR14 bitset< N > & | operator>>= (const uint32_t shift) |
| 右移赋值运算符 | |
| Public 成员函数 继承自 istringify< bitset< N > > | |
| NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string | to_string () const |
| 转换为字符串 | |
固定大小的位集
| N | 位数,在编译时确定 |
bitset表示一个固定大小的二进制位序列,提供对每个位的独立访问 以及常见的位操作(与、或、异或、移位等)。存储效率高,操作速度快。 位数N在编译时确定,因此不能动态改变大小。
在文件 bitset.hpp 第 34 行定义.
|
inlineexplicitconstexpr |
用字符串初始化bitset
| str | 字符串视图 |
| zero | 表示0的字符,默认为'0' |
| one | 表示1的字符,默认为'1' |
| value_exception | 如果字符串包含无效字符 |
字符串从左到右对应从高位到低位。如果字符串长度小于N,高位补0; 如果长度大于N,只使用前N个字符。
在文件 bitset.hpp 第 141 行定义.
引用了 basic_string_view< CharT, Traits >::length(), reset() , 以及 set().
将所有位重置为0
在文件 bitset.hpp 第 211 行定义.
引用了 bitset().
被这些函数引用 bitset(), operator<<=() , 以及 operator>>=().
将所有位设置为1
在文件 bitset.hpp 第 181 行定义.
引用了 bitset().
被这些函数引用 bitset() , 以及 bitset< N >::reference::reference().
|
inline |
转换为字符串
| zero | 表示0的字符 |
| one | 表示1的字符 |
在文件 bitset.hpp 第 552 行定义.
引用了 basic_string< CharT, Traits, Alloc >::push_back(), basic_string< CharT, Traits, Alloc >::reserve() , 以及 test().
|
inlineconstexprnoexcept |
转换为unsigned long long
| value_exception | 如果值超出unsigned long long范围 |
在文件 bitset.hpp 第 492 行定义.
|
inlineconstexprnoexcept |
转换为unsigned long
| value_exception | 如果值超出unsigned long范围 |
在文件 bitset.hpp 第 453 行定义.