set begin()检索最小元素? [英] set begin() retrieved the minimum element?

查看:279
本文介绍了set begin()检索最小元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如果我设置了< unsigned int> S;将*(s.begin())给我最小的

元素集合?如果没有,我该如何找回它?


干杯,


Paulo Matos

Hi,

If I have set<unsigned int> s; will *(s.begin()) give me the minimum
element of the set? If not, how can I retrieve it?

Cheers,

Paulo Matos

推荐答案

pmatos写道:
pmatos wrote:


如果我设置了< unsigned int> S;将*(s.begin())给我设置的最小元素?
Hi,

If I have set<unsigned int> s; will *(s.begin()) give me the minimum
element of the set?



默认情况下,是的。 Set是一个关联容器,它根据排序标准按排序顺序保存其元素

。默认排序

标准使用''<'',因此它将元素置于排序顺序中。你可以使用模板参数在编译时确定一个替代的排序标准

,或者在运行时确定一个构造函数参数(尽管那是一点点

棘手)。

-

如果我们的假设是关于任何东西而不是某个或多个特定的东西,那么我们的推论构成了数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题.- Bertrand Russell


pmatos写道:
pmatos wrote:


如果我设置了< unsigned int> S;会*(s.begin())给我这个集合的最小元素吗?
Hi,

If I have set<unsigned int> s; will *(s.begin()) give me the minimum
element of the set?




是的,虽然我会写s.front(相反。



Yes, though I''d write s.front() instead.


Rolf Magnus写道:
Rolf Magnus wrote:
pmatos写道:

pmatos wrote:



如果我设置了< unsigned int> S;将*(s.begin())给我设置的最小元素?
Hi,

If I have set<unsigned int> s; will *(s.begin()) give me the minimum
element of the set?



是的,虽然我会写s.front()而不是。


Yes, though I''d write s.front() instead.




只是为了完成......你最好确保套装不是空的:-)



Just to be complete...you''d better make sure the set isn''t empty :-)

这篇关于set begin()检索最小元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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