|
DAWorkbench 0.0.1
DAWorkbench API
|
基于 std::unordered_map 的稀疏表格数据结构 更多...
#include <da_hash_table.hpp>
Public 成员函数 | |
| da_hash_table (const da_hash_table &other)=default | |
| da_hash_table (da_hash_table &&other) noexcept=default | |
| da_hash_table (std::initializer_list< value_type > init) | |
| 初始化列表构造函数 | |
| da_hash_table & | operator= (const da_hash_table &other)=default |
| da_hash_table & | operator= (da_hash_table &&other) noexcept=default |
| T & | at (row_index_type r, col_index_type c) |
| 带边界检查的元素访问 | |
| const T & | at (row_index_type r, col_index_type c) const |
| 带边界检查的常量元素访问 | |
| T & | at (key_type k) |
| const T & | at (key_type k) const |
| T & | operator() (row_index_type r, col_index_type c) |
| 函数调用运算符访问元素 | |
| const T | operator() (row_index_type r, col_index_type c) const |
| 函数调用运算符访问元素(常量版本) | |
| T & | operator() (key_type k) |
| const T | operator() (key_type k) const |
| T | value (row_index_type r, col_index_type c) const |
| 安全的元素访问,返回默认值如果不存在 | |
| T | value (row_index_type r, col_index_type c, const T &defaultValue) const |
| 安全的元素访问,返回指定默认值如果不存在 | |
| T & | operator[] (key_type k) |
| bool | empty () const noexcept |
| 检查表格是否为空 | |
| size_type | size () const noexcept |
| 返回元素数量 | |
| size_type | max_size () const noexcept |
| 返回最大可能元素数量 | |
| void | clear () noexcept |
| 清空表格 | |
| std::pair< iterator, bool > | insert (const value_type &value) |
| 插入元素 | |
| template<class P > | |
| std::pair< iterator, bool > | insert (P &&value) |
| template<class InputIt > | |
| void | insert (InputIt first, InputIt last) |
| 插入元素范围 | |
| void | insert (std::initializer_list< value_type > ilist) |
| 插入初始化列表 | |
| template<class... Args> | |
| std::pair< iterator, bool > | emplace (Args &&... args) |
| iterator | erase (const_iterator pos) |
| 删除指定位置元素 | |
| iterator | erase (const_iterator first, const_iterator last) |
| 删除元素范围 | |
| size_type | erase (row_index_type r, col_index_type c) |
| 删除指定行列元素 | |
| iterator | find (key_type k) |
| 查找元素 | |
| const_iterator | find (key_type k) const |
| 查找元素 | |
| iterator | find (row_index_type r, col_index_type c) |
| 查找元素 | |
| const_iterator | find (row_index_type r, col_index_type c) const |
| 查找元素(常量版本) | |
| size_type | count (row_index_type r, col_index_type c) const |
| 统计元素出现次数 | |
| iterator | begin () noexcept |
| 返回指向起始的迭代器 | |
| const_iterator | begin () const noexcept |
| 返回指向起始的常量迭代器 | |
| const_iterator | cbegin () const noexcept |
| 返回指向起始的常量迭代器 | |
| iterator | end () noexcept |
| 返回指向末尾的迭代器 | |
| const_iterator | end () const noexcept |
| 返回指向末尾的常量迭代器 | |
| const_iterator | cend () const noexcept |
| 返回指向末尾的常量迭代器 | |
| float | load_factor () const noexcept |
| 返回当前负载因子 | |
| float | max_load_factor () const noexcept |
| 返回最大负载因子 | |
| void | max_load_factor (float ml) |
| 设置最大负载因子 | |
| void | rehash (size_type count) |
| 设置桶数并重新哈希 | |
| void | reserve (size_type count) |
| 预留空间 | |
| size_type | bucket_count () const noexcept |
| 返回桶数 | |
| size_type | max_bucket_count () const noexcept |
| 返回最大桶数 | |
| table_index_type | shape () const |
| 计算表格的形状(最大行索引和最大列索引加1) | |
| std::vector< row_index_type > | row_indices () const |
| 获取实际使用的行索引列表 | |
| std::vector< col_index_type > | column_indices () const |
| 获取实际使用的列索引列表 | |
| std::vector< std::pair< col_index_type, T > > | row (row_index_type r) const |
| 获取指定行的所有元素 | |
| std::vector< std::pair< row_index_type, T > > | column (col_index_type c) const |
| 获取指定列的所有元素 | |
| void | swap (da_hash_table &other) noexcept |
| 交换两个表格的内容 | |
| template<class P > | |
| std::pair< typename da_hash_table< T, row_index_type, col_index_type, hasher >::iterator, bool > | insert (P &&value) |
| 插入元素(通用引用) | |
| template<class... Args> | |
| std::pair< typename da_hash_table< T, row_index_type, col_index_type, hasher >::iterator, bool > | emplace (Args &&... args) |
| 原位构造元素 | |
基于 std::unordered_map 的稀疏表格数据结构
此类提供了一个稀疏表格数据结构,使用哈希表存储非默认值, 适合存储稀疏的二维数据,其中大部分元素为默认值。
| T | 存储的值类型 |
| row_index_type | 行索引类型,默认为 std::size_t |
| col_index_type | 列索引类型,默认为 row_index_type |
| hasher | 哈希函数类型,默认为 pair_hash |
| DA::da_hash_table< T, row_index_type, col_index_type, hasher >::da_hash_table | ( | std::initializer_list< value_type > | init | ) |
初始化列表构造函数
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| init | 初始化列表 |
| T & DA::da_hash_table< T, row_index_type, col_index_type, hasher >::at | ( | row_index_type | r, |
| col_index_type | c | ||
| ) |
带边界检查的元素访问
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| std::out_of_range | 如果元素不存在 |
| const T & DA::da_hash_table< T, row_index_type, col_index_type, hasher >::at | ( | row_index_type | r, |
| col_index_type | c | ||
| ) | const |
带边界检查的常量元素访问
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| std::out_of_range | 如果元素不存在 |
|
noexcept |
返回指向起始的常量迭代器
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回指向起始的迭代器
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回桶数
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回指向起始的常量迭代器
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回指向末尾的常量迭代器
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
清空表格
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| std::vector< std::pair< row_index_type, T > > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::column | ( | col_index_type | c | ) | const |
获取指定列的所有元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| c | 列索引 |
| std::vector< col_index_type > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::column_indices | ( | ) | const |
获取实际使用的列索引列表
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::size_type DA::da_hash_table< T, row_index_type, col_index_type, hasher >::count | ( | row_index_type | r, |
| col_index_type | c | ||
| ) | const |
统计元素出现次数
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| std::pair< typename da_hash_table< T, row_index_type, col_index_type, hasher >::iterator, bool > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::emplace | ( | Args &&... | args | ) |
原位构造元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| Args | 参数类型 |
| args | 构造参数 |
|
noexcept |
检查表格是否为空
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回指向末尾的常量迭代器
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回指向末尾的迭代器
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::iterator DA::da_hash_table< T, row_index_type, col_index_type, hasher >::erase | ( | const_iterator | first, |
| const_iterator | last | ||
| ) |
删除元素范围
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| first | 范围起始迭代器 |
| last | 范围结束迭代器 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::iterator DA::da_hash_table< T, row_index_type, col_index_type, hasher >::erase | ( | const_iterator | pos | ) |
删除指定位置元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| pos | 要删除的元素位置 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::size_type DA::da_hash_table< T, row_index_type, col_index_type, hasher >::erase | ( | row_index_type | r, |
| col_index_type | c | ||
| ) |
删除指定行列元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::iterator DA::da_hash_table< T, row_index_type, col_index_type, hasher >::find | ( | key_type | k | ) |
查找元素
| k | 键值 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::const_iterator DA::da_hash_table< T, row_index_type, col_index_type, hasher >::find | ( | key_type | k | ) | const |
查找元素
| k | 键值 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::iterator DA::da_hash_table< T, row_index_type, col_index_type, hasher >::find | ( | row_index_type | r, |
| col_index_type | c | ||
| ) |
查找元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::const_iterator DA::da_hash_table< T, row_index_type, col_index_type, hasher >::find | ( | row_index_type | r, |
| col_index_type | c | ||
| ) | const |
查找元素(常量版本)
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| std::pair< typename da_hash_table< T, row_index_type, col_index_type, hasher >::iterator, bool > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::insert | ( | const value_type & | value | ) |
插入元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| value | 要插入的元素 |
| void DA::da_hash_table< T, row_index_type, col_index_type, hasher >::insert | ( | InputIt | first, |
| InputIt | last | ||
| ) |
插入元素范围
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| InputIt | 输入迭代器类型 |
| first | 范围起始迭代器 |
| last | 范围结束迭代器 |
| std::pair< typename da_hash_table< T, row_index_type, col_index_type, hasher >::iterator, bool > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::insert | ( | P && | value | ) |
插入元素(通用引用)
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| P | 元素类型 |
| value | 要插入的元素 |
| void DA::da_hash_table< T, row_index_type, col_index_type, hasher >::insert | ( | std::initializer_list< value_type > | ilist | ) |
插入初始化列表
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| ilist | 初始化列表 |
|
noexcept |
返回当前负载因子
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回最大桶数
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回最大负载因子
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| void DA::da_hash_table< T, row_index_type, col_index_type, hasher >::max_load_factor | ( | float | ml | ) |
设置最大负载因子
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| ml | 新的最大负载因子 |
|
noexcept |
返回最大可能元素数量
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| T & DA::da_hash_table< T, row_index_type, col_index_type, hasher >::operator() | ( | row_index_type | r, |
| col_index_type | c | ||
| ) |
函数调用运算符访问元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| const T DA::da_hash_table< T, row_index_type, col_index_type, hasher >::operator() | ( | row_index_type | r, |
| col_index_type | c | ||
| ) | const |
函数调用运算符访问元素(常量版本)
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| void DA::da_hash_table< T, row_index_type, col_index_type, hasher >::rehash | ( | size_type | count | ) |
设置桶数并重新哈希
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| count | 新的桶数 |
| void DA::da_hash_table< T, row_index_type, col_index_type, hasher >::reserve | ( | size_type | count | ) |
预留空间
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| count | 要预留的元素数量 |
| std::vector< std::pair< col_index_type, T > > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::row | ( | row_index_type | r | ) | const |
获取指定行的所有元素
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| std::vector< row_index_type > DA::da_hash_table< T, row_index_type, col_index_type, hasher >::row_indices | ( | ) | const |
获取实际使用的行索引列表
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| da_hash_table< T, row_index_type, col_index_type, hasher >::table_index_type DA::da_hash_table< T, row_index_type, col_index_type, hasher >::shape | ( | ) | const |
计算表格的形状(最大行索引和最大列索引加1)
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
返回元素数量
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
|
noexcept |
交换两个表格的内容
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| other | 要交换的另一个表格 |
| T DA::da_hash_table< T, row_index_type, col_index_type, hasher >::value | ( | row_index_type | r, |
| col_index_type | c | ||
| ) | const |
安全的元素访问,返回默认值如果不存在
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| T DA::da_hash_table< T, row_index_type, col_index_type, hasher >::value | ( | row_index_type | r, |
| col_index_type | c, | ||
| const T & | defaultValue | ||
| ) | const |
安全的元素访问,返回指定默认值如果不存在
| T | 存储的值类型 |
| row_index_type | 行索引类型 |
| col_index_type | 列索引类型 |
| hasher | 哈希函数类型 |
| r | 行索引 |
| c | 列索引 |
| defaultValue | 指定的默认值 |