{"id":4332,"date":"2019-06-14T15:44:51","date_gmt":"2019-06-14T07:44:51","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4332"},"modified":"2019-06-17T09:23:13","modified_gmt":"2019-06-17T01:23:13","slug":"%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9ajdk6%e4%b8%ba%e5%95%a5%e9%bb%98%e8%ae%a4%e6%8e%92%e5%ba%8f%e6%98%af%e5%bd%92%e5%b9%b6%e6%8e%92%e5%ba%8f%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4332","title":{"rendered":"\u9762\u8bd5\u9898\uff1aJDK6\u4e3a\u5565\u9ed8\u8ba4\u6392\u5e8f\u662f\u5f52\u5e76\u6392\u5e8f\u5462\uff1f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u8fd9\u662f\u56e0\u4e3a Java \u505a\u4e3a\u4e00\u4e2a\u5e73\u53f0\u578b\u8bed\u8a00\uff0c\u5bf9\u4e8e\u7a33\u5b9a\u6027\u8981\u6c42\u8f83\u9ad8\uff01\u5f52\u5e76\u6709\u4e00\u4e2a\u5feb\u6392\u6ca1\u6709\u7684\u4f18\u70b9\uff0c\u5c31\u662f\u5f52\u5e76\u6392\u5e8f\u662f\u7a33\u5b9a\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u4e3a\u5408\u5e76\u6392\u5e8f\u6bd4\u8f83\u7a33\u5b9a\uff0c\u6bd4\u5feb\u6392\u7a33\u5b9a\uff0c\u5feb\u6392\u6709\u53ef\u80fd\u65f6\u95f4\u590d\u6742\u5ea6\u8fbe\u5230 O(n ^ 2)\uff0c\u4f46\u662f\u5408\u5e76\u6392\u5e8f\u5c31\u76f8\u5bf9\u8d8b\u4e8e O(nlogn)\uff0c\u4f46\u662f\u5408\u5e76\u6392\u5e8f\u7684\u4e00\u4e2a\u7f3a\u70b9\u5c31\u662f\u8981\u7528\u5230\u4e24\u4e2a\u4e34\u65f6\u7684\u6570\u7ec4\u5185\u5b58\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f88\u591a\u4eba\u53ef\u80fd\u4e0d\u7406\u89e3\u4ec0\u4e48\u662f\u7a33\u5b9a\uff1f\u7ed9\u4f60\u4e3e\u4e2a\u4f8b\u5b50\u5427\u3002[1,2,1,3] \u6392\u5e8f\u8fc7\u540e\u6210\u4e3a [1, 1, 2, 3]\u3002\u4f7f\u7528\u5feb\u901f\u6392\u5e8f\u540e\uff0c\u8fd9\u4e24\u4e2a 1 \u53ef\u80fd\u5c31\u6362\u4e86\u4e2a\u4f4d\u7f6e\u3002\u8fd9\u91cc\u7528\u5355\u7eaf\u7684\u6570\u5b57\uff0c\u4f60\u53ef\u80fd\u770b\u4e0d\u51fa\u6765\u6548\u679c\u3002\u4f46\u662f\u5982\u679c\u662f\u7528\u5bf9\u8c61\u6bd4\u8f83\u7684\u8bdd\uff0c\u5047\u5982\u4e24\u4e2a\u5bf9\u8c61\u7684 compare \u503c\u662f\u5bf9\u7b49\u7684\uff0c\u4f46\u662f\u6392\u5e8f\u8fc7\u540e\u76f8\u4e92\u987a\u5e8f\u5374\u53d8\u4e86\uff0c\u5728\u5185\u5b58\u4e0a\u662f\u6709\u610f\u4e49\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53e6\u5916\uff0c\u5feb\u6392\u662f\u4e0d\u662f\u6700\u5feb\u7684\u6392\u5e8f\u7b97\u6cd5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 JDK8 \u4e2d\uff0c\u5982\u679c\u4f60\u770b\u8fc7\u6e90\u7801\u5c31\u4f1a\u77e5\u9053\uff0c\u5176\u5b9e\u9488\u5bf9\u4e0d\u540c\u7684\u60c5\u51b5\u4f7f\u7528\u4e86\u4e0d\u540c\u7684\u6392\u5e8f\u7b97\u6cd5\uff0c\u7b80\u5355\u7f57\u5217\u4e0b\uff1a1.\u5982\u679c\u662f\u7b80\u5355\u5bf9\u8c61\u6570\u636e\uff0c\u4f8b\u5982int\uff0cdouble\uff0c\u4e14\u6570\u7ec4\u957f\u5ea6\u5728\u4e00\u5b9a\u9600\u503c\u5185\uff0c\u5219\u4f7f\u7528\u5feb\u6392\uff0c\u5982\u679c\u5728\u9600\u503c\u5916\uff0c\u5219\u7528\u5f52\u5e76\uff1b\u5982\u679c\u662f\u590d\u6742\u5bf9\u8c61\u6570\u7ec4\uff0c\u5219\u5982\u679c\u6570\u7ec4\u957f\u5ea6\u5728\u4e00\u5b9a\u9600\u503c\u4ee5\u5185\uff0c\u5219\u4f7f\u7528\u6298\u534a\u63d2\u5165\u6392\u5e8f\uff0c\u5982\u679c\u957f\u5ea6\u5728\u9600\u503c\u5916\uff0c\u5219\u4f7f\u7528\u5f52\u5e76\u6cd5\uff0c\u4f46\u662f\u5982\u679c\u5f52\u5e76\u4e8c\u5206\u540e\u5c0f\u4e8e\u9600\u503c\u4e86\uff0c\u5219\u5728\u5185\u90e8\u8fd8\u662f\u4f1a\u4f7f\u7528\u6298\u534a\u63d2\u5165\u6392\u5e8f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u4e3a\u4ec0\u4e48\u590d\u6742\u5bf9\u8c61\u4e0d\u4f7f\u7528\u5feb\u901f\u6392\u5e8f\u5462\uff1f\u56e0\u4e3a\u5bf9\u4e8e\u4e00\u4e2a hashcode \u8ba1\u7b97\u590d\u6742\u7684\u5bf9\u8c61\u6765\u8bf4\uff0c\u79fb\u52a8\u7684\u6210\u672c\u8fdc\u4f4e\u4e8e\u6bd4\u8f83\u7684\u6210\u672c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g40q994bhxj20h60gj0u6.jpg\" alt=\"\" \/><figcaption>\u5f52\u5e76\u6392\u5e8f\u8fc7\u7a0b<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f52\u5e76\u6392\u5e8f\u5728\u6700\u574f\u60c5\u51b5\u4e0b\u7684\u952e\u503c\u6bd4\u8f83\u6b21\u6570\u5341\u5206\u63a5\u8fd1\u57fa\u4e8e\u6bd4\u8f83\u7684\u6392\u5e8f\u7b97\u6cd5\u5728\u7406\u8bba\u4e0a\u80fd\u591f\u8fbe\u5230\u7684\u6700\u5c11\u6b21\u6570\u3002\u5f53n\u5f88\u5927\u65f6\uff0c\u5f52\u5e76\u6392\u5e8f\u7b97\u6cd5\u6bd4\u8f83\u7684\u6b21\u6570\u662f\u8981\u5c0f\u4e8e0.25n\u6b21\u7684\uff0c\u56e0\u6b64\u6548\u7387\u4e5f\u5c5e\u4e8e\u03b8(nlogn)\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u76f8\u6bd4\u4e8e\u5feb\u901f\u6392\u5e8f\u548c\u5806\u6392\u5e8f\uff0c\u5f52\u5e76\u7b97\u6cd5\u7684\u4e00\u4e2a\u663e\u8457\u4f18\u70b9\u5728\u4e8e\u5176\u7a33\u5b9a\u6027\uff0c\u4e3b\u8981\u7f3a\u70b9\u5728\u4e8e\u9700\u8981\u7ebf\u6027\u7684\u989d\u5916\u7a7a\u95f4\u3002\u5f52\u5e76\u7b97\u6cd5\u4e5f\u53ef\u4ee5\u505a\u5230\u539f\u5730\u6392\u5e8f\uff0c\u4f7f\u7a7a\u95f4\u590d\u6742\u5ea6\u964d\u81f3 O(1)\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f52\u5e76\u6392\u5e8f\u6709\u4e24\u7c7b\u4e3b\u8981\u7684\u53d8\u5316\u5f62\u5f0f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7b97\u6cd5\u81ea\u5e95\u5411\u4e0a\u5408\u5e76\u6570\u7ec4\u7684\u4e00\u4e2a\u4e2a\u5143\u7d20\u5bf9\uff0c\u7136\u540e\u518d\u5408\u5e76\u6709\u4e9b\u6709\u5e8f\u5bf9\uff0c\u4f9d\u6b21\u7c7b\u63a8\u3002\u8fd9\u79cd\u65b9\u5f0f\u662f\u8fed\u4ee3\u5f0f\u7684\uff0c\u56e0\u6b64\u907f\u514d\u4e86\u4f7f\u7528\u5806\u6808\u5904\u7406\u9012\u5f52\u8c03\u7528\u65f6\u7684\u7a7a\u95f4\u548c\u65f6\u95f4\u5f00\u9500\u3002<\/li><li>\u7b97\u6cd5\u628a\u6570\u7ec4\u5212\u5206\u4e3a\u5f85\u6392\u5e8f\u7684\u591a\u4e2a\u90e8\u5206\uff0c\u518d\u5bf9\u5b83\u4eec\u9012\u5f52\u6392\u5e8f\uff0c\u6700\u540e\u5c06\u5176\u5408\u5e76\u5728\u4e00\u8d77\u3002\u8fd9\u4e2a\u65b9\u6848\u5c24\u5176\u9002\u5408\u5bf9\u5b58\u653e\u5728\u4e8c\u7ea7\u5b58\u50a8\u7a7a\u95f4\uff08\u5185\u5b58-\u5916\u5b58\uff09\u7684\u6587\u4ef6\u8fdb\u884c\u6392\u5e8f\uff0c\u4e5f\u88ab\u79f0\u4e3a\u591a\u8def\u5f52\u5e76\u6392\u5e8f(multiway mergesort)\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u5e0c\u671b\u80fd\u591f\u5e2e\u52a9\u5927\u5bb6\u89e3\u60d1\uff01<\/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=4332\">\u9762\u8bd5\u9898\uff1aJDK6\u4e3a\u5565\u9ed8\u8ba4\u6392\u5e8f\u662f\u5f52\u5e76\u6392\u5e8f\u5462\uff1f<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u56e0\u4e3a Java \u505a\u4e3a\u4e00\u4e2a\u5e73\u53f0\u578b\u8bed\u8a00\uff0c\u5bf9\u4e8e\u7a33\u5b9a\u6027\u8981\u6c42\u8f83\u9ad8\uff01\u5f52\u5e76\u6709\u4e00\u4e2a\u5feb\u6392\u6ca1\u6709\u7684\u4f18\u70b9\uff0c\u5c31\u662f\u5f52\u5e76\u6392\u5e8f\u662f\u7a33\u5b9a\u7684\u3002  [&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],"tags":[173,175,172,75,410],"class_list":["post-4332","post","type-post","status-publish","format-standard","hentry","category-java","tag-173","tag-175","tag-172","tag-75","tag-410"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4332","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=4332"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4332\/revisions"}],"predecessor-version":[{"id":4344,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4332\/revisions\/4344"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}