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

std::multiset

Defined in header <set>

template< class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> > class multiset;

(1)

namespace pmr { template <class Key, class Compare = std::less<Key>> using multiset = std::multiset<Key, Compare, std::pmr::polymorphic_allocator<Key>>; }

(2)

(since C++17)

std::multiset是一个关联容器,它包含一组类型为键的排序对象。与SET不同,允许具有等效值的多个键。排序是使用键比较函数进行比较。搜索、插入和删除操作具有对数复杂度。

标准库在任何地方使用Compare概念,等价物是通过使用上面描述的等价关系来确定的。Compare不精确地说,有两个物体ab如果两者之间的比较都不低于其他值,则被认为是等效的:!comp(a, b) && !comp(b, a)...

比较等效元素的顺序是插入的顺序,不改变。%28自C++11%29。

std::multiset满足…的要求Container,,,AllocatorAwareContainer,,,AssociativeContainerReversibleContainer...

成员类型

Member type

Definition

key_type

Key

value_type

Key

size_type

Unsigned integer type (usually std::size_t)

difference_type

Signed integer type (usually std::ptrdiff_t)

key_compare

Compare

value_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)

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)

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)

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)

Allocator::const_pointer

(until C++11)

std::allocator_traits<Allocator>::const_pointer

(since C++11)

iterator

BidirectionalIterator (until C++11) Constant BidirectionalIterator (since C++11)

BidirectionalIterator

(until C++11)

Constant BidirectionalIterator

(since C++11)

BidirectionalIterator

(until C++11)

Constant BidirectionalIterator

(since C++11)

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)

成员函数

(constructor)

constructs the multiset (public member function)

(destructor)

destructs the multiset (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<operator<=operator>operator>=

lexicographically compares the values in the multiset (function template)

std::swap(std::multiset)

specializes the std::swap algorithm (function template)

注记

成员类型iteratorconst_iterator可能是同一类型的别名。自iterator可转换为const_iterator,,,const_iterator应在函数参数列表中使用,以避免违反“一个定义规则”。

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

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

扫码关注腾讯云开发者

领取腾讯云代金券