久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 std::map 和 std::unordered_map 之間進行選擇

Choosing between std::map and std::unordered_map(在 std::map 和 std::unordered_map 之間進行選擇)
本文介紹了在 std::map 和 std::unordered_map 之間進行選擇的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

既然 stdunordered_map 中有一個真正的哈希映射,為什么(或何時)我還想使用舊的 mapunordered_map 在它實際存在的系統(tǒng)上?是否有任何我無法立即看到的明顯情況?

Now that std has a real hash map in unordered_map, why (or when) would I still want to use the good old map over unordered_map on systems where it actually exists? Are there any obvious situations that I cannot immediately see?

推薦答案

As 已經(jīng)提到,map 允許以排序的方式迭代元素,但unordered_map 不允許.這在許多情況下非常重要,例如顯示集合(例如地址簿).這也體現(xiàn)在其他間接方式上,例如:(1) 從 find() 返回的迭代器開始迭代,或 (2) 存在像 lower_bound() 這樣的成員函數(shù).

As already mentioned, map allows to iterate over the elements in a sorted way, but unordered_map does not. This is very important in many situations, for example displaying a collection (e.g. address book). This also manifests in other indirect ways like: (1) Start iterating from the iterator returned by find(), or (2) existence of member functions like lower_bound().

此外,我認為在最壞情況 搜索復雜性方面存在一些差異.

Also, I think there is some difference in the worst case search complexity.

  • 對于map,是O(lg N)

對于unordered_map,它是O( N ) [當哈希函數(shù)不好導致太多哈希沖突時,可能發(fā)生這種情況.]

For unordered_map, it is O( N ) [This may happen when the hash function is not good leading to too many hash collisions.]

同樣適用于最壞情況 刪除復雜性.

這篇關于在 std::map 和 std::unordered_map 之間進行選擇的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Assertion failed (size.widthgt;0 amp;amp; size.heightgt;0)(斷言失敗(size.width0 amp;amp; size.height0))
Rotate an image in C++ without using OpenCV functions(在 C++ 中旋轉(zhuǎn)圖像而不使用 OpenCV 函數(shù))
OpenCV: process every frame(OpenCV:處理每一幀)
Why can#39;t I open avi video in openCV?(為什么我不能在 openCV 中打開 avi 視頻?)
OpenCV unable to set up SVM Parameters(OpenCV 無法設置 SVM 參數(shù))
Convert a single color with cvtColor(使用 cvtColor 轉(zhuǎn)換單一顏色)
主站蜘蛛池模板: 午夜大片| 狠狠躁夜夜躁人人爽天天高潮 | 久久久一区二区 | 91精品国产高清一区二区三区 | 久久不卡| 国产精品久久一区二区三区 | 国产在线中文字幕 | 欧美日韩国产在线 | 国产我和子的乱视频网站 | 一级免费a | 成人性视频免费网站 | 九九热视频这里只有精品 | 久久国产一区二区三区 | 蜜桃av一区二区三区 | 91久久久www播放日本观看 | 久久久国产亚洲精品 | 精品久久久久久亚洲精品 | 日日日操 | 国产精品揄拍一区二区 | 亚洲视频国产视频 | 伊人久久一区二区 | 日韩一区二区三区在线看 | 国产精品18hdxxxⅹ在线 | 国产一级成人 | 久久精品国产一区 | 日韩精品 电影一区 亚洲 | 夜夜草| 国产精品日韩一区二区 | 在线看av网址 | 蜜桃传媒av | 日韩高清中文字幕 | 中文字幕影院 | 成人午夜精品 | 日韩在线观看中文字幕 | 91精品久久久久久久久中文字幕 | 国产日韩欧美激情 | www.亚洲视频| 久久中文字幕一区 | 羞羞的视频在线 | 成人在线一区二区三区 | 国产黄色一级片 |