|
|
| sparse_vector ()=default |
| | 默认构造函数
|
| | sparse_vector (const Compare &comp) |
| | 构造函数,指定比较函数
|
| | sparse_vector (const sparse_vector &other) |
| | 拷贝构造函数
|
| sparse_vector & | operator= (const sparse_vector &other) |
| | 拷贝赋值运算符
|
| | sparse_vector (sparse_vector &&other) noexcept(is_nothrow_move_constructible_v< container_type > &&is_nothrow_move_constructible_v< Compare > &&is_nothrow_move_constructible_v< KeyOfValue >) |
| | 移动构造函数
|
| sparse_vector & | operator= (sparse_vector &&other) noexcept(is_nothrow_move_assignable_v< container_type >) |
| | 移动赋值运算符
|
|
| ~sparse_vector ()=default |
| | 析构函数
|
| iterator | begin () noexcept |
| | 获取起始迭代器
|
| iterator | end () noexcept |
| | 获取结束迭代器
|
| const_iterator | begin () const noexcept |
| | 获取常量起始迭代器
|
| const_iterator | end () const noexcept |
| | 获取常量结束迭代器
|
| const_iterator | cbegin () const noexcept |
| | 获取常量起始迭代器
|
| const_iterator | cend () const noexcept |
| | 获取常量结束迭代器
|
| reverse_iterator | rbegin () noexcept |
| | 获取反向起始迭代器
|
| reverse_iterator | rend () noexcept |
| | 获取反向结束迭代器
|
| const_reverse_iterator | rbegin () const noexcept |
| | 获取常量反向起始迭代器
|
| const_reverse_iterator | rend () const noexcept |
| | 获取常量反向结束迭代器
|
| const_reverse_iterator | crbegin () const noexcept |
| | 获取常量反向起始迭代器
|
| const_reverse_iterator | crend () const noexcept |
| | 获取常量反向结束迭代器
|
| size_type | size () const noexcept |
| | 获取元素数量
|
| size_type | max_size () const noexcept |
| | 获取最大可能大小
|
| bool | empty () const noexcept |
| | 检查是否为空
|
| Compare | key_compare () const noexcept(is_nothrow_copy_constructible_v< Compare >) |
| | 获取键比较函数对象
|
| template<typename... Args> |
| pair< iterator, bool > | emplace_unique (Args &&... args) |
| | 插入唯一键元素
|
| pair< iterator, bool > | insert_unique (const value_type &value) |
| | 拷贝插入唯一键元素
|
| pair< iterator, bool > | insert_unique (value_type &&value) |
| | 移动插入唯一键元素
|
| template<typename... Args> |
| iterator | emplace_unique_hint (iterator position, Args &&... args) |
| | 在提示位置附近构造唯一键元素
|
| iterator | insert_unique (iterator position, const value_type &value) |
| | 在提示位置附近拷贝插入唯一键元素
|
| iterator | insert_unique (iterator position, value_type &&value) |
| | 在提示位置附近移动插入唯一键元素
|
| template<typename Iterator, enable_if_t< is_iter_v< Iterator >, int > = 0> |
| void | insert_unique (Iterator first, Iterator last) |
| | 范围插入唯一键元素
|
| template<typename... Args> |
| iterator | emplace_equal (Args &&... args) |
| | 插入允许重复键元素
|
| iterator | insert_equal (const value_type &value) |
| | 拷贝插入允许重复键元素
|
| iterator | insert_equal (value_type &&value) |
| | 移动插入允许重复键元素
|
| template<typename... Args> |
| iterator | emplace_equal_hint (iterator position, Args &&... args) |
| | 在提示位置附近构造允许重复键元素
|
| iterator | insert_equal (iterator position, const value_type &value) |
| | 在提示位置附近拷贝插入允许重复键元素
|
| iterator | insert_equal (iterator position, value_type &&value) |
| | 在提示位置附近移动插入允许重复键元素
|
| template<typename Iterator, enable_if_t< is_iter_v< Iterator >, int > = 0> |
| void | insert_equal (Iterator first, Iterator last) |
| | 范围插入允许重复键元素
|
| size_type | erase (const key_type &key) |
| | 删除所有具有指定键的元素
|
| void | erase (iterator position) |
| | 删除指定位置的元素
|
| void | erase (iterator first, iterator last) |
| | 删除指定范围内的元素
|
|
void | clear () |
| | 清空
|
| iterator | find (const key_type &key) |
| | 查找具有指定键的元素
|
| const_iterator | find (const key_type &key) const |
| | 查找具有指定键的元素(常量版本)
|
| size_type | count (const key_type &key) const |
| | 统计具有指定键的元素数量
|
| iterator | lower_bound (const key_type &key) |
| | 获取第一个不小于指定键的元素位置
|
| const_iterator | lower_bound (const key_type &key) const |
| | 获取第一个不小于指定键的元素位置(常量版本)
|
| iterator | upper_bound (const key_type &key) |
| | 获取第一个大于指定键的元素位置
|
| const_iterator | upper_bound (const key_type &key) const |
| | 获取第一个大于指定键的元素位置(常量版本)
|
| pair< iterator, iterator > | equal_range (const key_type &key) |
| | 获取等于指定键的元素范围
|
| pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
| | 获取等于指定键的元素范围(常量版本)
|
| void | reserve (size_type n) |
| | 预留容量
|
| size_type | capacity () const noexcept |
| | 获取当前容量
|
|
void | shrink_to_fit () |
| | 收缩容量以适应实际大小
|
| void | swap (sparse_vector &other) noexcept(is_nothrow_swappable_v< container_type > &&is_nothrow_swappable_v< Compare > &&is_nothrow_swappable_v< KeyOfValue >) |
| | 交换两个稀疏向量的内容
|
| bool | equal_to (const sparse_vector &rhs) const noexcept(noexcept(_NEFORCE equal(cbegin(), cend(), rhs.cbegin()))) |
| | 相等比较
|
| bool | less_than (const sparse_vector &rhs) const noexcept(noexcept(_NEFORCE lexicographical_compare(cbegin(), cend(), rhs.cbegin(), rhs.cend()))) |
| | 小于比较
|
template<typename Key, typename Value, typename KeyOfValue, typename Compare, typename Alloc = allocator<Value>>
class neforce::sparse_vector< Key, Value, KeyOfValue, Compare, Alloc >
稀疏向量容器
- 模板参数
-
| Key | 键类型 |
| Value | 值类型 |
| KeyOfValue | 从值中提取键的函数对象 |
| Compare | 键比较函数对象 |
| Alloc | 分配器类型 |
稀疏向量是一种基于有序平坦数组的关联容器底层实现。 使用二分查找提供对数时间复杂度的查找操作。
- 注解
- 稀疏向量在插入/删除时需要移动元素,但迭代性能优异,缓存友好,适用于查找频繁、修改较少且需要有序遍历的场景。
在文件 sparse_vector.hpp 第 191 行定义.