博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++ std::multiset
阅读量:5285 次
发布时间:2019-06-14

本文共 2282 字,大约阅读时间需要 7 分钟。

std::multiset

template < class T,                        // multiset::key_type/value_type           class Compare = less
, // multiset::key_compare/value_compare class Alloc = allocator
> // multiset::allocator_type > class multiset;

Multiple-key set

Multisets are containers that store elements following a specific order, and where multiple elements can have equivalent values.

In a multiset, the value of an element also identifies it (the value is itself the key, of type T). The value of the elements in a multiset cannot be modified once in the container (the elements are always const), but they can be inserted or removed from the container.

Internally, the elements in a multiset are always sorted following a specific strict weak ordering criterion indicated by its internal comparison object (of type Compare).

multiset containers are generally slower than unordered_multiset containers to access individual elements by their key, but they allow the direct iteration on subsets based on their order.

Multisets are typically implemented as binary search trees.

Container properties

  • Associative Elements in associative containers are referenced by their key and not by their absolute position in the container.
  • Ordered The elements in the container follow a strict order at all times. All inserted elements are given a position in this order.
  • Set The value of an element is also the key used to identify it.
  • Multiple equivalent keys Multiple elements in the container can have equivalent keys.
  • Allocator-aware The container uses an allocator object to dynamically handle its storage needs.

** Other Function please see the std::set container **

Code Example

#include 
#include
using namespace std;bool fncomp(int lhs, int rhs){ return lhs < rhs; }struct classcomp{ bool operator() (const int& lhs, const int& rhs) const { return lhs
first; int myints[] = {10,20,30,20,20}; multiset
first1(myints, myints+5); multiset
first2(first1); multiset
first3(first2.begin(),first2.end()); multiset
first4; bool (*fn_pt)(int,int) = fncomp; multiset
first5(fn_pt); /** other function please to reference other container */ return 0;}

Reference

转载于:https://www.cnblogs.com/zi-xing/p/6259399.html

你可能感兴趣的文章
skiing
查看>>
wxwidgets demo
查看>>
dubbo 实战总结
查看>>
bzoj1230 [Usaco2008 Nov]lites 开关灯
查看>>
Modulation of Lipid Metabolism by Celastrol (文献分享一组-赵倩倩)
查看>>
HDU 1044 Collect More Jewels(BFS+DFS)
查看>>
TrackbarCallback 回调函数必须为 void(int,void*)
查看>>
【BZOJ1857】[Scoi2010]传送带 三分法
查看>>
得到相册里面的全部图片
查看>>
JPA与Spring2.5整合时发生不能创建entityManagerFactory的问题解决方法
查看>>
FastDFS 初始
查看>>
选项卡
查看>>
14-----定时器
查看>>
XidianOJ 1028 数字工程
查看>>
派遣函数
查看>>
教程6--配置ssh
查看>>
C#串口扫描枪的简单实现
查看>>
SharePoint各版本信息
查看>>
Python数据结构——散列表
查看>>
.Net学习笔记----2015-07-08(基础复习和练习03)
查看>>