std::multimap
STD:多倍
Defined in header | | |
---|---|---|
template< class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T> > > class multimap; | (1) | |
namespace pmr { template <class Key, class T, class Compare = std::less<Key>> using multimap = std::multimap<Key, T, Compare, std::pmr::polymorphic_allocator<std::pair<const Key,T>>>; } | (2) | (since C++17) |
Multimap是一个关联容器,它包含一个排序的键值对列表,同时允许具有相同键的多个条目。排序是根据比较函数进行的。Compare
应用在钥匙上。搜索、插入和删除操作具有对数复杂度。
键比较等价的键值对的顺序是插入的顺序,不改变。%28自C++11%29。
标准库在任何地方使用Compare
概念,等价物是通过使用上面描述的等价关系来确定的。Compare
不精确地说,有两个物体a
和b
如果两者之间的比较都不低于其他值,则被认为是等效的:!comp(a, b) && !comp(b, a)
...
std::multimap
满足…的要求Container
,,,AllocatorAwareContainer
,,,AssociativeContainer
和ReversibleContainer
...
成员类型
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) |
key_compare | Compare |
allocator_type | Allocator |
reference | Allocator::reference (until C++11) value_type& (since C++11) |
Allocator::reference | (until C++11) |
value_type& | (since C++11) |
const_reference | Allocator::const_reference (until C++11) const value_type& (since C++11) |
Allocator::const_reference | (until C++11) |
const value_type& | (since C++11) |
pointer | Allocator::pointer (until C++11) std::allocator_traits<Allocator>::pointer (since C++11) |
Allocator::pointer | (until C++11) |
std::allocator_traits<Allocator>::pointer | (since C++11) |
const_pointer | Allocator::const_pointer (until C++11) std::allocator_traits<Allocator>::const_pointer (since C++11) |
Allocator::const_pointer | (until C++11) |
std::allocator_traits<Allocator>::const_pointer | (since C++11) |
iterator | BidirectionalIterator |
const_iterator | Constant bidirectional iterator |
reverse_iterator | std::reverse_iterator<iterator> |
const_reverse_iterator | std::reverse_iterator<const_iterator> |
node_type | a specialization of node handle representing a container node (since C++17) |
成员类
value_compare | compares objects of type value_type (class) |
---|
成员函数
(constructor) | constructs the multimap (public member function) |
---|---|
(destructor) | destructs the 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
rend crend将反向迭代器返回到End%28公共成员函数%29
容量
空检查容器是否为空%28公共成员函数%29
Size返回元素数%28公共成员函数%29
马克斯[医]Size返回元素的最大可能数%28公共成员函数%29
修饰符
清除内容%28公共成员功能%29
插入元素或节点%28,因为C++17%29%28公共成员函数%29
嵌入%28C++11%29构造元素就地%28公共成员函数%29
座落[医]提示%28C++11%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公共成员函数%29。
上层[医]绑定将迭代器返回给大于给定键%28公共成员函数%29的第一个元素。
观察员
键[医]COMP返回比较键%28公共成员函数%29的函数
价值[医]COMP返回比较值类型对象中键的函数。[医]类型%28公共成员功能%29
非会员职能
operator==operator!=operator | lexicographically compares the values in the multimap (function template) |
---|---|
std::swap(std::multimap) | specializes the std::swap algorithm (function template) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。