首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::unordered_multimap

Defined in header <unordered_map>

template< class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator< std::pair<const Key, T> > > class unordered_multimap;

(1)

(since C++11)

namespace pmr { template <class Key, class T, class Hash = std::hash<Key>, class Pred = std::equal_to<Key>> using unordered_multimap = std::unordered_multimap<Key, T, Hash, Pred, std::pmr::polymorphic_allocator<std::pair<const Key,T>>>; }

(2)

(since C++17)

无序多用户协议是一个无序关联容器,它支持等价键%28 a无序。[医]Multimap可以包含每个键值%29的多个副本,并将另一类型的值与键关联。无序[医]Multimap类支持前向迭代器。搜索、插入和删除具有平均恒定时间复杂度.

在内部,元素不是按任何特定的顺序排序,而是组织成桶。将元素放入哪个桶完全取决于其键的散列。这允许快速访问各个元素,因为一旦计算了散列,它就会引用该元素被放置到的确切桶。

这个容器的迭代顺序不要求是稳定的%28so,例如,std::equal不能用来比较两个std::unordered_multimapS%29,但其键比较的每一组元素除外等价物%28相等于key_eq()由于比较器%29按迭代顺序形成一个连续的子范围,也可以用equal_range()...

std::unordered_multimap满足…的要求Container,,,AllocatorAwareContainer,,,UnorderedAssociativeContainer...

成员类型

Member type

Definition

key_type

Key

mapped_type

T

value_type

std::pair<const Key, T>

size_type

Unsigned integer type (usually std::size_t)

difference_type

Signed integer type (usually std::ptrdiff_t)

hasher

Hash

key_equal

KeyEqual

allocator_type

Allocator

reference

value_type&

const_reference

const value_type&

pointer

std::allocator_traits<Allocator>::pointer

const_pointer

std::allocator_traits<Allocator>::const_pointer

iterator

ForwardIterator

const_iterator

Constant forward iterator

local_iterator

An iterator type whose category, value, difference, pointer and reference types are the same as iterator. This iterator can be used to iterate through a single bucket but not across buckets

const_local_iterator

An iterator type whose category, value, difference, pointer and reference types are the same as const_iterator. This iterator can be used to iterate through a single bucket but not across buckets

node_type

a specialization of node handle representing a container node (since C++17)

成员函数

(constructor)

constructs the unordered_multimap (public member function)

(destructor)

destructs the unordered_multimap (public member function)

operator=

assigns values to the container (public member function)

get_allocator

returns the associated allocator (public member function)

迭代器

BEGINCBEGIN将迭代器返回到开头%28的公共成员函数%29

End cend将迭代器返回到End%28公共成员函数%29

容量

空检查容器是否为空%28公共成员函数%29

Size返回元素数%28公共成员函数%29

马克斯[医]Size返回元素的最大可能数%28公共成员函数%29

修饰符

清除内容%28公共成员功能%29

插入元素或节点%28,因为C++17%29%28公共成员函数%29

嵌入构造元素就地%28公共成员函数%29

座落[医]提示使用提示%28公共成员函数%29就地构造元素。

擦除元素%28公共成员函数%29

交换交换内容%28公共成员函数%29

提取%28C++17%29从容器中提取节点%28公共成员函数%29

从另一个容器合并%28C++17%29个连接节点%28公共成员函数%29

查找

Count返回匹配特定键的元素数%28公共成员函数%29

查找具有特定密钥%28公共成员函数%29的查找元素

平等[医]范围返回匹配特定键%28公共成员函数%29的元素的范围

桶接口

开始%28 int%29 cBEGIN%28 int%29返回一个迭代器到指定桶%28公共成员函数%29的开头

End%28 int%29 cend%28 int%29返回一个迭代器到指定桶%28公共成员函数%29的末尾

斗[医]Count返回桶数%28公共成员函数%29

马克斯[医]斗[医]COUNT返回最大桶数%28公共成员函数%29

斗[医]Size返回特定桶%28公共成员函数中的元素数%29

桶返回特定键%28公共成员函数%29的桶

散列策略

负载[医]因子返回每个桶的平均元素数%28公共成员函数%29

马克斯[医]负载[医]因子管理每个桶的最大平均元素数%28公共成员函数%29

重新哈希至少保留指定数量的桶。这将重新生成哈希表。28%公共成员职能%29

储备空间至少保留指定数量的元素。这将重新生成哈希表。28%公共成员职能%29

观察员

散列[医]函数返回函数用于散列键%28公共成员函数%29

键[医]Eq返回用于比较相等性%28公共成员函数%29的键的函数。

非会员职能

operator==operator!=

compares the values in the unordered_multimap (function template)

std::swap(std::unordered_multimap) (C++11)

specializes the std::swap algorithm (function template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券