{"id":1529,"date":"2018-07-20T20:40:06","date_gmt":"2018-07-20T12:40:06","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=1529"},"modified":"2018-07-20T20:40:06","modified_gmt":"2018-07-20T12:40:06","slug":"c-%e5%a4%b4%e6%96%87%e4%bb%b6%e7%b3%bb%e5%88%97unordered_map%e3%80%81unordered_set","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/1529","title":{"rendered":"C++ \u5934\u6587\u4ef6\u7cfb\u5217(unordered_map\u3001unordered_set)"},"content":{"rendered":"<h1 class=\"postTitle\"><a id=\"cb_post_title_url\" class=\"postTitle2\" href=\"https:\/\/www.cnblogs.com\/lgxZJ\/p\/6351470.html\">C++ \u5934\u6587\u4ef6\u7cfb\u5217(unordered_map\u3001unordered_set)<\/a><\/h1>\n<div class=\"clear\"><\/div>\n<div class=\"postBody\">\n<div id=\"cnblogs_post_body\" class=\"blogpost-body cnblogs-markdown\">\n<h2 id=\"\u7b80\u4ecb\">\u7b80\u4ecb<\/h2>\n<p>\u5f88\u660e\u663e\uff0c\u8fd9\u4e24\u4e2a\u5934\u6587\u4ef6\u5206\u522b\u662fmap\u3001set\u5934\u6587\u4ef6\u5bf9\u5e94\u7684unordered\u7248\u672c\u3002 \u6240\u4ee5\u5b83\u4eec\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u6027\u8d28\u5c31\u662f\uff1a<\/p>\n<ul>\n<li>\u4e71\u5e8f<\/li>\n<\/ul>\n<h2 id=\"\u5982\u4f55\u4e71\u5e8f\">\u5982\u4f55\u4e71\u5e8f<\/h2>\n<p>\u8fd9\u4e2aunorder\u6697\u793a\u7740\uff0c\u8fd9\u4e24\u4e2a\u5934\u6587\u4ef6\u4e2d\u7c7b\u7684\u5e95\u5c42\u5b9e\u73b0&#8212;-<strong>Hash<\/strong>\u3002 \u4e5f\u662f\u56e0\u4e3a\u5982\u6b64\uff0c\u4f60\u624d\u53ef\u4ee5\u5728\u58f0\u660e\u8fd9\u4e9bunordered\u6a21\u7248\u7c7b\u7684\u65f6\u5019\uff0c\u4f20\u5165\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u54c8\u5e0c\u51fd\u6570\uff0c\u51c6\u786e\u7684\u8bf4\u662f<strong>\u54c8\u5e0c\u51fd\u6570\u5b50<\/strong>\uff08hash function object\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/ooo.0o0.ooo\/2017\/01\/26\/588967ca7c706.png\" \/><\/p>\n<p>\u5177\u6709\u76f8\u540c\u76f8\u540c\u54c8\u5e0c\u503c\u7684\u5143\u7d20\u88ab\u653e\u5728\u540c\u4e00\u4e2a\u6876\uff08bucket\uff09\u4e2d\u3002<\/p>\n<h2 id=\"\u4e3a\u4f55\u4e71\u5e8f\">\u4e3a\u4f55\u4e71\u5e8f<\/h2>\n<p><strong>\u5728\u63d0\u4f9b\u6620\u5c04\u3001\u96c6\u5408\u529f\u80fd\u7684\u60c5\u51b5\u4e0b\uff0c\u4fa7\u91cd\u4e8e\u5143\u7d20\u7684\u5feb\u901f\u83b7\u53d6<\/strong>\u3002<\/p>\n<p>\u7528\u6811\u7ed3\u6784\uff08\u7ea2\u9ed1\u6811\u3001\u4e8c\u53c9\u641c\u7d22\u6811\u7b49\uff09\u5b9e\u73b0\u7684map\u3001set\uff0c\u5728\u67e5\u627e\u3001\u83b7\u53d6\u3001\u4fee\u6539\u5143\u7d20\u7684\u65f6\u5019\uff0c\u901a\u5e38\u9700\u8981\u4ece\u6839\u7ed3\u70b9\u81ea\u4e0a\u800c\u4e0b\u4e00\u6b21\u904d\u5386\u6811\u7ed3\u6784\uff0c\u56e0\u6b64<strong>\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a\u7ebf\u6027<\/strong>\u00a0\uff1b \u800c\u901a\u8fc7\u54c8\u5e0c\u8868\u5b9e\u73b0\uff0c \u53ea\u8981\u54c8\u5e0c\u51fd\u6570\u4ee5\u53ca\u6876\u7684\u5927\u5c0f\u9009\u53d6\u5f97\u5f53\uff0c<strong>\u65f6\u95f4\u590d\u6742\u5ea6\u4f1a\u662f\u5e38\u6570<\/strong>\uff08\u53ea\u9700\u8981\u8c03\u7528\u4e00\u6b21\u51fd\u6570\uff0c\u5e76\u8fdb\u884c\u5c0f\u5e45\u5ea6\u7684\u67e5\u627e\uff09\u3002<\/p>\n<h2 id=\"\u5355\u5411\u8fed\u4ee3\u5668\">\u5355\u5411\u8fed\u4ee3\u5668<\/h2>\n<p>\u54c8\u5e0c\u8868\u7684\u5b9e\u73b0\u590d\u6742\u4e86\u8be5\u5bb9\u5668\u4e0a\u7684\u53cc\u5411\u904d\u5386\uff0c\u4f3c\u4e4e\u6ca1\u6709\u4e00\u79cd\u5408\u9002\u7684\u65b9\u6cd5\u80fd\u591f\u505a\u5230\u9ad8\u6548\u5feb\u901f\u3002 \u56e0\u6b64\uff0cunorder\u7248\u672c\u7684map\u548cset\u53ea\u63d0\u4f9b<strong>\u524d\u5411\u8fed\u4ee3\u5668<\/strong>\uff08\u975eunorder\u7248\u672c\u63d0\u4f9b\u53cc\u5411\u8fed\u4ee3\u5668\uff09\u3002<\/p>\n<h2 id=\"\u5c11\u4e86\u4ec0\u4e48\u51fd\u6570\">\u5c11\u4e86\u4ec0\u4e48\u51fd\u6570<\/h2>\n<ul>\n<li>lower_bound<\/li>\n<li>upper_bound<\/li>\n<\/ul>\n<p>\u666e\u901a\u7248\u672c\u7684map\u548cset\uff0c\u5b83\u4eec\u662f\u6709\u5e8f\u5bb9\u5668\uff0c\u5bf9\u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u80fd\u90fd\u80fd\u5224\u65ad\u5b83\u5e94\u8be5\u5728\u54ea\u4e2a\u4e4b\u524d\u3001\u5728\u54ea\u4e2a\u4e4b\u540e\uff1b \u800c\u8be5\u7248\u672c\u7684\u5bb9\u5668\u5219\u4e0d\u4e00\u6837\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f<strong>\u4e71\u5e8f<\/strong>\u7684\uff0c<strong>\u4e0d\u80fd\u786e\u5b9a\u6bcf\u4e2a\u5143\u7d20\u7684\u5148\u540e\u987a\u5e8f<\/strong>\u3002 \u56e0\u6b64\uff0c\u5bb9\u5668\u6ca1\u6709\u8db3\u591f\u7684\u4fe1\u606f\u6765\u8ba1\u7b97\u8fd9\u4e24\u4e2a\u8fb9\u754c\uff08\u7136\u800c\u5143\u7d20\u7684\u76f8\u7b49\u6027\u6bd4\u8f83\u4f9d\u65e7\u662f\u53ef\u884c\u7684\uff09\u3002<\/p>\n<h2 id=\"\u591a\u4e86\u4ec0\u4e48\u51fd\u6570\">\u591a\u4e86\u4ec0\u4e48\u51fd\u6570<\/h2>\n<p>\u51fa\u4e8e\u5b9e\u73b0\u7684\u6982\u5ff5\uff0c\u8be5\u7248\u672c\u7684\u7c7b\u6a21\u7248\u5fc5\u4e0d\u53ef\u5c11\u7684\u591a\u4e86\u4e9b\u7279\u6b8a\u7684\u51fd\u6570\u3002<\/p>\n<h3 id=\"\u6876\u76f8\u5173bucket\">\u6876\u76f8\u5173\uff08Bucket\uff09<\/h3>\n<ul>\n<li>bucket_count \uff1a \u6876\u6570\u91cf\u3002<\/li>\n<li>max_bucket_count \uff1a \u6700\u5927\u6876\u6570\u91cf\u3002<\/li>\n<li>bucket_size \uff1a \u6876\u5927\u5c0f\uff0c\u5373\u5bb9\u91cf\u3002<\/li>\n<li>bucket \uff1a \u5b9a\u4f4d\u7ed9\u5b9a\u5143\u7d20\u7684\u6876\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<h3 id=\"\u54c8\u5e0c\u7b56\u7565\">\u54c8\u5e0c\u7b56\u7565<\/h3>\n<ul>\n<li>load_factor \uff1a \u8fd4\u56de<strong>load factor<\/strong>\uff0c\u5373<strong>\u5bb9\u5668\u5f53\u524d\u5143\u7d20\u6570\u91cf\u4e0e\u6876\u6570\u91cf\u4e4b\u6bd4<\/strong>\u3002<\/li>\n<li>max_load_factor \uff1a \u8fd4\u56de\u6216\u8bbe\u7f6e\u6700\u5927load factor\u3002<\/li>\n<li>rehash \uff1a \u8bbe\u7f6e\u6876\u7684\u6570\u91cf\uff0c\u5e76\u91cd\u65b0\u5bf9\u5143\u7d20\u8fdb\u884c\u54c8\u5e0c\u6620\u5c04\u3002<\/li>\n<li>reserve \uff1a\u00a0<strong>\u8bf7\u6c42<\/strong>\u4fdd\u7559\u6876\u7684\u6570\u91cf\u81f3\u7ed9\u5b9a\u503c\u3002<\/li>\n<\/ul>\n<p>\u6ce8\u610f\u5230\uff0c\u6ca1\u6709\u51fd\u6570\u80fd\u6539\u53d8\u6876\u7684\u5bb9\u91cf\uff0c<strong>\u53ef\u80fd\u6876\u4e5f\u662f\u52a8\u6001\u589e\u957f\u7684<\/strong>\u3002<\/p>\n<h3 id=\"observers\">Observers<\/h3>\n<ul>\n<li>hash_function : \u8fd4\u56de\u54c8\u5e0c\u51fd\u6570\uff08<strong>\u5728\u58f0\u660e\u65f6\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\uff0c\u6216\u9ed8\u8ba4\u7684\u4f4d\u4e8efuntional\u5934\u6587\u4ef6\u4e2d\u7684hash<\/strong>\uff09\u3002<\/li>\n<li>key_eq : \u8fd4\u56dekey\u7684\u76f8\u7b49\u6027\u8c13\u8bcd\uff0c\u60c5\u51b5\u4e0ehash_function\u76f8\u4f3c\u3002<\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>C++ \u5934\u6587\u4ef6\u7cfb\u5217(unordered_<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[118],"class_list":["post-1529","post","type-post","status-publish","format-standard","hentry","tag-02-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/1529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=1529"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}