Is the unordered_map really unordered?

前端 未结 5 2027
悲哀的现实
悲哀的现实 2020-12-06 06:07

I am very confused by the name \'unordered_map\'. The name suggests that the keys are not ordered at all. But I always thought they are ordered by their hash value. Or is th

5条回答
  •  既然无缘
    2020-12-06 06:36

    If you want an analogy, look at the RDBMS of your choice.

    If you don't specify an ORDER BY clause when performing a query, the results are returned "unordered" - that is, in whatever order the database feels like. The order is not specified, and the system is free to "order" them however it likes in order to get the best performance.

提交回复
热议问题