两个相同的unordered_maps的顺序是否相同? [英] Is the order of two same unordered_maps the same?

查看:79
本文介绍了两个相同的unordered_maps的顺序是否相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

换句话说,如果我填写两个 unordered_map unordered_set ,则内容完全相同且哈希函数相同的对象将对其进行迭代,从而给出相同的顺序键/值对?

In other words, if I fill two unordered_map, or unordered_set, objects with exactly the same content and the same hashing function, will iterating over them give the same sequence of key/value pairs?

如果是,那么要满足的条件是什么(例如,相同的哈希函数,相同的键,不一定是相同的值).

If so, then what are the conditions for this to hold (e.g. same hashing function, same keys, not necessarily same values).

推荐答案

否.例如,不要求将具有相同散列的对象以任何特定顺序放置.实际上,一般来说,无序映射是不可能做到这一点的,因为它只能访问的信息就是哈希值.

No. There is no requirement, for example, that objects that have the same hash be placed in any particular order. In fact, in general it's impossible for an unordered map to do this because the only information it has access to is the hash value.

这篇关于两个相同的unordered_maps的顺序是否相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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