std :: multimap< key,value>之间有什么区别?和std :: map< key,std :: set< value> > [英] What's the difference between std::multimap<key, value> and std::map<key, std::set<value> >

查看:385
本文介绍了std :: multimap< key,value>之间有什么区别?和std :: map< key,std :: set< value> >的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现他们有一个键和多个值是唯一的。

I found that they have one key and multiple values which is unique.

推荐答案

值),其中key和value都可以出现多次。

The multimap stores pairs of (key, value) where both key and value can appear several times.

map< key,set< value>> 只会为特定键存储每个值一次。为了做到这一点,它必须能够比较值,而不仅仅是键。

The map<key, set<value>> will only store each value once for a specific key. To do that, it will have to be able to compare the values, not just the keys.

根据您的应用程序,如果相等的值相等,或者如果您希望单独存储它们。也许它们包含不同的字段,但不参与该集合的比较。

It depends on your application if the values that compare equal are equivalent, or if you wish to store them separately anyway. Perhaps they contain fields that are different but do not take part in the comparison for the set.

这篇关于std :: multimap&lt; key,value&gt;之间有什么区别?和std :: map&lt; key,std :: set&lt; value&gt; &GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆