{"id":3381,"date":"2018-11-20T09:54:35","date_gmt":"2018-11-20T01:54:35","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3381"},"modified":"2018-11-20T09:54:35","modified_gmt":"2018-11-20T01:54:35","slug":"hashmap-%e5%ad%98%e5%9c%a8%e7%9a%84%e6%84%8f%e4%b9%89%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3381","title":{"rendered":"HashMap \u5b58\u5728\u7684\u610f\u4e49\u662f\u4ec0\u4e48?"},"content":{"rendered":"<p>\n\t\u6211\u4e00\u76f4\u5728\u601d\u8003\u4e00\u4e2a\u95ee\u9898\uff1aHashMap \u5b58\u5728\u7684\u610f\u4e49\u662f\u4ec0\u4e48\uff1f\u4e5f\u5c31\u662f\u8bf4 Java \u4e3a\u4ec0\u4e48\u8981\u8bbe\u8ba1 HashMap\uff1f\u6211\u95ee\u4e86\u5f88\u591a\u9762\u8bd5\u8005\u4ee5\u53ca\u5f88\u591a CSDN \u7684\u535a\u5ba2\u4e13\u5bb6\u90fd\u6ca1\u6709\u627e\u5230\u60f3\u8981\u7684\u7b54\u6848\uff01\u4e8e\u662f\u6211\u81ea\u5df1\u67e5\u4e86\u5f88\u591a\u8d44\u6599\u60f3\u627e HashMap \u4e3a\u4ec0\u4e48\u9700\u8981\u8fd9\u6837\u8bbe\u8ba1\uff1f\u6700\u7ec8\u90fd\u6ca1\u6709\u7ed3\u679c\uff01\n<\/p>\n<p>\n\t\u6ca1\u6709\u7ed3\u679c\u4f60\u8fd8\u5199\u8fd9\u7bc7\u6587\u7ae0\u5e72\u5565\uff1f\u867d\u7136\u6ca1\u6709\u7ed3\u679c\uff0c\u4f46\u662f\u6211\u53c8\u91cd\u65b0\u770b\u4e86\u4e00\u904d HashMap \u7684\u6e90\u7801\uff0c\u5f97\u51fa\u4e86\u4e00\u4e9b\u7ed3\u8bba\u3002\u6211\u60f3\u8fd9\u53ef\u80fd\u5c31\u662f HashMap \u8bbe\u8ba1\u7684\u521d\u8877\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u4e0d\u6b63\u786e\u7684\u5730\u65b9\u5e0c\u671b\u5927\u5bb6\u6307\u51fa\uff0c\u6211\u4eec\u5171\u540c\u8fdb\u6b65\uff01\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"HashMap \u5b58\u5728\u7684\u610f\u4e49\u662f\u4ec0\u4e48?\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/hashmap-reason.png\" style=\"width: 510px;height: 340px\" \/>\n<\/p>\n<p>\n\t\u524d\u9762\u6211\u8bb2\u8fc7 ArrayList \u548c LinkedList\uff0c\u8fd8\u6709 Vector\u3002\u4f46\u662f\u5b83\u4eec\u90fd\u53c8\u4e00\u4e9b\u7f3a\u70b9\uff0c\u8981\u4e48\u63d2\u5165\u5220\u9664\u901f\u5ea6\u6162\u3001\u8981\u4e48\u5c31\u662f\u904d\u5386\u901f\u5ea6\u6162\u3002\u90a3\u4e48\u6709\u6ca1\u6709\u4e00\u79cd\u63d2\u5165\u3001\u5220\u9664\u3001\u904d\u5386\u90fd\u6bd4\u8f83\u4e0d\u9519\u7684\u96c6\u5408\u7c7b\u5462\uff1f\n<\/p>\n<p>\n\t\u4e8e\u662f HashMap \u5c31\u51fa\u73b0\u4e86\u3002HashMap \u53ef\u4ee5\u5b58\u50a8\u4e00\u7ec4\u952e\u503c\u5bf9\u7684\u96c6\u5408\uff0c\u5e76\u5b9e\u73b0\u5feb\u901f\u7684\u67e5\u627e\u3002\n<\/p>\n<ul>\n<li>\n\t\t\u4e3a\u4e86\u5b9e\u73b0\u5feb\u901f\u67e5\u627e\uff0cHashMap \u9009\u62e9\u4e86\u6570\u7ec4\u800c\u4e0d\u662f\u94fe\u8868\u3002\u4ee5\u5229\u7528\u6570\u7ec4\u7684\u7d22\u5f15\u5b9e\u73b0 O(1) \u590d\u6742\u5ea6\u7684\u67e5\u627e\u6548\u7387\u3002\n\t<\/li>\n<li>\n\t\t\u4e3a\u4e86\u5229\u7528\u7d22\u5f15\u67e5\u627e\uff0cHashMap \u5f15\u5165 Hash \u7b97\u6cd5, \u5c06 key \u6620\u5c04\u6210\u6570\u7ec4\u4e0b\u6807: key -&gt; Index\u3002\n\t<\/li>\n<li>\n\t\t\u5f15\u5165 Hash \u7b97\u6cd5\u53c8\u5bfc\u81f4\u4e86 Hash \u51b2\u7a81\u3002\n\t<\/li>\n<li>\n\t\t\u4e3a\u4e86\u89e3\u51b3 Hash \u51b2\u7a81\uff0cHashMap \u91c7\u7528\u94fe\u5730\u5740\u6cd5\uff0c\u5728\u51b2\u7a81\u4f4d\u7f6e\u8f6c\u4e3a\u4f7f\u7528\u94fe\u8868\u5b58\u50a8\u3002\n\t<\/li>\n<li>\n\t\t\u94fe\u8868\u5b58\u50a8\u8fc7\u591a\u7684\u8282\u70b9\u53c8\u5bfc\u81f4\u4e86\u5728\u94fe\u8868\u4e0a\u8282\u70b9\u7684\u67e5\u627e\u6027\u80fd\u7684\u6076\u5316\u3002\n\t<\/li>\n<li>\n\t\t\u4e3a\u4e86\u4f18\u5316\u67e5\u627e\u6027\u80fd\uff0cHashMap \u5728\u94fe\u8868\u957f\u5ea6\u8d85\u8fc7 8 \u4e4b\u540e\u8f6c\u800c\u5c06\u94fe\u8868\u8f6c\u53d8\u6210\u7ea2\u9ed1\u6811\uff0c\u4ee5\u5c06 O(n) \u590d\u6742\u5ea6\u7684\u67e5\u627e\u6548\u7387\u63d0\u5347\u81f3 O(log n)\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u73b0\u5728\u6211\u4eec\u662f\u4e0d\u662f\u53ef\u4ee5\u5f97\u51fa\u4e00\u79cd\u7ed3\u8bba\u3002\n<\/p>\n<p>\n\tHashMap \u5b58\u5728\u7684\u610f\u4e49\u5c31\u662f\u5b9e\u73b0\u4e00\u79cd\u5feb\u901f\u7684\u67e5\u627e\u5e76\u4e14\u63d2\u5165\u3001\u5220\u9664\u6027\u80fd\u90fd\u4e0d\u9519\u7684\u4e00\u79cd K\/V\uff08key\/value\uff09\u6570\u636e\u7ed3\u6784\u3002\n<\/p>\n<p>\n\t\u5173\u4e8e\u7f16\u7a0b\uff0c\u6211\u5e0c\u671b\u5927\u5bb6\u6bcf\u5929\u90fd\u6709\u4e00\u4e9b\u601d\u8003\uff0c\u8fd9\u6837\u80fd\u6210\u957f\u7684\u66f4\u5feb\uff01\n<\/p>\n<p>\n\t\u6700\u540e\u6211\u7559\u4e00\u4e2a\u5c0f\u95ee\u9898\uff0cHashMap \u5220\u9664\u5143\u7d20\uff0c\u6570\u7ec4\u4f1a\u79fb\u52a8\u5417\uff1f<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3381\">HashMap \u5b58\u5728\u7684\u610f\u4e49\u662f\u4ec0\u4e48?<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6211\u4e00\u76f4\u5728\u601d\u8003\u4e00\u4e2a\u95ee\u9898\uff1aHashMap \u5b58\u5728\u7684\u610f\u4e49\u662f\u4ec0\u4e48\uff1f\u4e5f\u5c31\u662f\u8bf4 Java \u4e3a\u4ec0\u4e48\u8981\u8bbe\u8ba1 HashMap\uff1f\u6211\u95ee [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[1741,1164,1161,1163,1743],"class_list":["post-3381","post","type-post","status-publish","format-standard","hentry","category-java","category-yyzt","tag-arraylist","tag-concurrenthashmap","tag-hashmap","tag-linkedhashmap","tag-linkedlist"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3381"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3381\/revisions"}],"predecessor-version":[{"id":3382,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3381\/revisions\/3382"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}