提高:: unordered_map保持插入的顺序? [英] boost::unordered_map maintains order of insertion?

查看:3611
本文介绍了提高:: unordered_map保持插入的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找它提供的std ::地图一样的界面,但仍保持在哪些元素插入的顺序的容器。既然不会在地图上太​​多的元素,查找性能是不是一个大问题。将提振::在这种情况下unordered_map 工作?即它保持插入的顺序。我是新来Boost库,因此想要知道究竟是什么意思通过'无序'?

I am looking for a container which provides std::map like interface but maintains the order in which elements are inserted. Since there will not be too many elements in the map, the lookup performance is not a big issue. Will boost::unordered_map work in this case? i.e. does it maintain the order of insertion. I am new to boost library and hence want to know what exactly meant by 'unordered' ?

推荐答案

unordered_map不保持插入的顺序。无序在这种情况下,意味着元素的观察到的顺序(当你一一列举,即)是不确定的,并且武断。事实上,我希望,在一个unordered_map元素的顺序可以在地图的生命周期中的变化,由于调整地图时老调重弹(这是依赖于实现虽然)

unordered_map doesn't maintain the order of insertion. Unordered in this case means that the observable order of elements (i.e. when you enumerate them) is unspecified and arbitrary. In fact, I would expect that the order of elements in an unordered_map can change during the lifetime of the map, due to rehashing when resizing the map (that's implementation dependent though)

这篇关于提高:: unordered_map保持插入的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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