|
| | hashtable (const size_type n, float max_lf=1.0f) |
| | 构造函数
|
| | hashtable (const size_type n, const HashFcn &hf, float max_lf=1.0f) |
| | 构造函数,指定哈希函数
|
| | hashtable (const size_type n, const HashFcn &hf, const EqualKey &eql, float max_lf=1.0f) |
| | 构造函数,指定哈希函数和相等比较函数
|
| | hashtable (const size_type n, const HashFcn &hf, const EqualKey &eql, const ExtractKey &ext, float max_lf=1.0f) |
| | 构造函数,指定所有函数对象
|
| | hashtable (const hashtable &other) |
| | 拷贝构造函数
|
| hashtable & | operator= (const hashtable &other) |
| | 拷贝赋值运算符
|
| | hashtable (hashtable &&other) noexcept(noexcept(hashtable::swap(other))) |
| | 移动构造函数
|
| hashtable & | operator= (hashtable &&other) noexcept(noexcept(hashtable::swap(other))) |
| | 移动赋值运算符
|
|
| ~hashtable () |
| | 析构函数
|
| NEFORCE_NODISCARD iterator | begin () noexcept |
| | 获取起始迭代器
|
| NEFORCE_NODISCARD iterator | end () noexcept |
| | 获取结束迭代器
|
| NEFORCE_NODISCARD const_iterator | begin () const noexcept |
| | 获取常量起始迭代器
|
| NEFORCE_NODISCARD const_iterator | end () const noexcept |
| | 获取常量结束迭代器
|
| NEFORCE_NODISCARD const_iterator | cbegin () const noexcept |
| | 获取常量起始迭代器
|
| NEFORCE_NODISCARD const_iterator | cend () const noexcept |
| | 获取常量结束迭代器
|
| NEFORCE_NODISCARD size_type | size () const noexcept |
| | 获取元素数量
|
| NEFORCE_NODISCARD size_type | max_size () const noexcept |
| | 获取最大可能大小
|
| NEFORCE_NODISCARD bool | empty () const noexcept |
| | 检查是否为空
|
| NEFORCE_NODISCARD size_type | buckets_size () const noexcept |
| | 获取桶数量
|
| NEFORCE_NODISCARD size_type | bucket_index (const key_type &key) const noexcept(is_nothrow_hashable_v< key_type >) |
| | 获取键的桶索引
|
| NEFORCE_NODISCARD size_type | bucket_size (size_type index) const noexcept |
| | 获取指定桶的大小
|
| NEFORCE_NODISCARD hasher | hash_func () const noexcept(is_nothrow_copy_constructible_v< hasher >) |
| | 获取哈希函数对象
|
| NEFORCE_NODISCARD key_equal | key_eql () const noexcept(is_nothrow_copy_constructible_v< key_equal >) |
| | 获取键相等比较函数对象
|
| NEFORCE_NODISCARD float | load_factor () const noexcept |
| | 获取当前负载因子
|
| NEFORCE_NODISCARD float | max_load_factor () const noexcept |
| | 获取最大负载因子
|
| void | max_load_factor (const float lf) noexcept |
| | 设置最大负载因子
|
| void | rehash (const size_type new_size) |
| | 重新哈希,调整桶数量
|
| void | reserve (const size_type n) |
| | 预留空间
|
| template<typename... Args> |
| pair< iterator, bool > | emplace_unique (Args &&... args) |
| | 构造元素(唯一键版本)
|
| template<typename... Args> |
| iterator | emplace_equal (Args &&... args) |
| | 构造元素(允许重复键版本)
|
| pair< iterator, bool > | insert_unique (const value_type &value) |
| | 插入元素(唯一键版本)
|
| pair< iterator, bool > | insert_unique (value_type &&value) |
| | 移动插入元素(唯一键版本)
|
| iterator | insert_equal (const value_type &value) |
| | 插入元素(允许重复键版本)
|
| iterator | insert_equal (value_type &&value) |
| | 移动插入元素(允许重复键版本)
|
| template<typename Iterator> |
| enable_if_t< is_iter_v< Iterator > > | insert_unique (Iterator first, Iterator last) |
| | 范围插入元素(唯一键版本)
|
| void | insert_unique (std::initializer_list< value_type > ilist) |
| | 初始化列表插入元素(唯一键版本)
|
| template<typename Iterator> |
| enable_if_t< is_iter_v< Iterator > > | insert_equal (Iterator first, Iterator last) |
| | 范围插入元素(允许重复键版本)
|
| void | insert_equal (std::initializer_list< value_type > ilist) |
| | 初始化列表插入元素(允许重复键版本)
|
| size_type | erase (const key_type &key) noexcept(is_nothrow_hashable_v< key_type >) |
| | 删除所有具有指定键的元素
|
| iterator | erase (const iterator &position) noexcept(is_nothrow_hashable_v< key_type >) |
| | 删除指定位置的元素
|
| iterator | erase (iterator first, iterator last) noexcept(is_nothrow_hashable_v< key_type >) |
| | 删除指定范围内的元素
|
| const_iterator | erase (const const_iterator &position) noexcept(is_nothrow_hashable_v< key_type >) |
| | 删除指定位置的元素(常量迭代器版本)
|
| const_iterator | erase (const_iterator first, const_iterator last) noexcept(is_nothrow_hashable_v< key_type >) |
| | 删除指定范围内的元素(常量迭代器版本)
|
|
void | clear () noexcept |
| | 清空哈希表
|
| NEFORCE_NODISCARD iterator | find (const key_type &key) noexcept(is_nothrow_hashable_v< key_type >) |
| | 查找具有指定键的元素
|
| NEFORCE_NODISCARD const_iterator | find (const key_type &key) const noexcept(is_nothrow_hashable_v< key_type >) |
| | 查找具有指定键的元素(常量版本)
|
| NEFORCE_NODISCARD size_type | count (const key_type &key) const noexcept(is_nothrow_hashable_v< key_type >) |
| | 统计具有指定键的元素数量
|
| NEFORCE_NODISCARD bool | contains (const key_type &key) const noexcept(is_nothrow_hashable_v< key_type >) |
| | 检查是否包含指定键
|
| NEFORCE_NODISCARD pair< iterator, iterator > | equal_range (const key_type &key) |
| | 获取等于指定键的元素范围
|
| NEFORCE_NODISCARD pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
| | 获取等于指定键的元素范围(常量版本)
|
| void | swap (hashtable &other) noexcept(is_nothrow_swappable_v< HashFcn > &&is_nothrow_swappable_v< EqualKey > &&is_nothrow_swappable_v< allocator_type >) |
| | 交换两个哈希表的内容
|
| NEFORCE_NODISCARD bool | operator== (const hashtable &rhs) const |
| | 相等比较操作符
|
| NEFORCE_NODISCARD bool | operator< (const hashtable &rhs) const noexcept(noexcept(_NEFORCE lexicographical_compare(hashtable::cbegin(), hashtable::cend(), rhs.cbegin(), rhs.cend()))) |
| | 小于比较操作符
|
| NEFORCE_NODISCARD constexpr decltype(auto) | size () const noexcept(noexcept(derived().size())) |
| | 获取集合大小
|
| NEFORCE_NODISCARD constexpr bool | empty () const noexcept(noexcept(derived().empty())) |
| | 检查集合是否为空
|
| NEFORCE_NODISCARD constexpr bool | operator== (const hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc > &rhs) const noexcept(noexcept(derived()==rhs)) |
| | 相等比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator!= (const hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc > &rhs) const noexcept(noexcept(!(*this==rhs))) |
| | 不等比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator< (const hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc > &rhs) const noexcept(noexcept(derived()< rhs)) |
| | 小于比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator> (const hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc > &rhs) const noexcept(noexcept(rhs< derived())) |
| | 大于比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator<= (const hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc > &rhs) const noexcept(noexcept(!(derived() > rhs))) |
| | 小于等于比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator>= (const hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc > &rhs) const noexcept(noexcept(!(derived()< rhs))) |
| | 大于等于比较运算符
|
template<typename Value, typename Key, typename HashFcn, typename ExtractKey, typename EqualKey, typename Alloc>
class hashtable< Value, Key, HashFcn, ExtractKey, EqualKey, Alloc >
哈希表容器
- 模板参数
-
| Value | 值类型 |
| Key | 键类型 |
| HashFcn | 哈希函数类型 |
| ExtractKey | 从值中提取键的函数对象类型 |
| EqualKey | 键相等比较函数对象类型 |
| Alloc | 分配器类型 |
哈希表使用链地址法处理冲突,采用素数表确定桶数量,提供平均常数时间复杂度的 插入、删除和查找操作。支持唯一键和允许重复键两种模式。
在文件 hashtable.hpp 第 289 行定义.