{"id":6097,"date":"2020-08-14T17:34:07","date_gmt":"2020-08-14T09:34:07","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=6097"},"modified":"2020-08-14T17:34:10","modified_gmt":"2020-08-14T09:34:10","slug":"python-%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84%e5%92%8c%e7%ae%97%e6%b3%95-06-%e5%a6%82%e4%bd%95%e7%90%86%e8%a7%a3%e5%9f%ba%e7%a1%80%e7%9a%84%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84-2","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=6097","title":{"rendered":"Python \u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5 06| \u5982\u4f55\u7406\u89e3\u57fa\u7840\u7684\u6570\u636e\u7ed3\u6784\u2014\u2014\u961f\u5217"},"content":{"rendered":"\n<h2><strong>\u961f\u5217<\/strong><\/h2>\n\n\n\n<p>\u4f60\u5403\u5b8c\u4e1c\u897f\u540e\u6709\u5e8f\u62c9\u51fa\u6765\u7684\u8fc7\u7a0b\uff0c\u5c31\u662f\u961f\u5217\u3002<\/p>\n\n\n\n<p>\u548c\u6808\u8fd9\u79cd\u6570\u636e\u7ed3\u6784\u4e0d\u540c\u7684\u662f\uff0c\u961f\u5217\u53ef\u4ee5\u5b58\u5165\u548c\u53d6\u51fa\u6570\u636e\uff0c\u4e0d\u8fc7\u5b83\u5177\u6709 \u201c\u5148\u8fdb\u5148\u51fa\u201d \u7684\u7279\u70b9\uff0c\u5b83\u6709\u4e24\u4e2a\u4e3b\u8981\u7684\u64cd\u4f5c\uff1a\u5165\u961f\u548c\u51fa\u961f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"696\" height=\"111\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/08\/Untitled-Diagram.png\" alt=\"\" class=\"wp-image-6098\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/08\/Untitled-Diagram.png 696w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/08\/Untitled-Diagram-300x48.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/figure><\/div>\n\n\n\n<p>\u5176\u5b9e\u4f60\u5728\u751f\u6d3b\u8fc7\u7a0b\u4e2d\u5c31\u7ecf\u5e38\u9047\u5230 \u201c\u961f\u5217\u201d\uff0c\u6bd4\u5982\u4f60\u6392\u961f\u8fdb\u9ad8\u94c1\u68c0\u7968\u7684\u65f6\u5019\uff0c\u6392\u5728\u524d\u9762\u7684\u4eba\u5c31\u5148\u8fdb\u53bb\uff0c\u6392\u5230\u540e\u9762\u7684\u4eba\u5c31\u53ea\u80fd\u6162\u6162\u7b49\uff08\u5f53\u7136\uff0c\u8fd9\u91cc\u4e0d\u8ba8\u8bba\u63d2\u961f\u548c\u4e2d\u9014\u6392\u961f\u9000\u51fa\u7684\u60c5\u51b5\uff09\u3002<\/p>\n\n\n\n<h2><strong>\u961f\u5217<\/strong>\u7684\u5b9e\u73b0\u5b9e\u4f8b<\/h2>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u7528 Python \u7684 list \u6765\u6f14\u793a\u4e00\u4e0b\u961f\u5217\u7684\u7b80\u5355\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u961f\u5217 Queue \u7684\u7c7b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"300\" height=\"100\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/08\/Screenshot-from-2020-08-14-17-02-08.png\" alt=\"\" class=\"wp-image-6100\"\/><\/figure><\/div>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u521d\u59cb\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86 items \u5217\u8868\uff0c\u7528\u6765\u5b58\u50a8\u6570\u636e\uff0c\u800c count \u7528\u6765\u5b9a\u4e49\u5b58\u50a8\u6570\u636e\u7684\u5927\u5c0f\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u9700\u8981\u5b9a\u4e49\u4e24\u4e2a\u4e3b\u8981\u7684\u64cd\u4f5c\uff0c\u4e00\u4e2a\u662f\u5165\u961f enqueue\uff0c\u4e00\u4e2a\u662f\u51fa\u961f dequeue\uff1a<div style=\"text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;\">\u672c\u6587\u9690\u85cf\u5185\u5bb9 <a href=\"https:\/\/vip.fxxkpython.com\/wp-login.php?redirect_to=https%3A%2F%2Fvip.fxxkpython.com%2F%3Fp%3D6097\">\u767b\u9646<\/a> \u540e\u624d\u53ef\u4ee5\u6d4f\u89c8<\/div>\u800c\u5728\u51fa\u961f\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u4e5f\u662f O(1),  \u800c\u5982\u679c\u5143\u7d20\u5b58\u50a8\u5230 n \u7684\u65f6\u5019\uff0c\u9700\u8981\u505a\u6570\u636e\u6574\u4f53\u7684\u642c\u79fb\u624d\u80fd\u518d\u6b21\u63d2\u5165\u6570\u636e\uff0c\u90a3\u4e48\u8fd9\u65f6\u5019\u7684\u5165\u961f\u65f6\u95f4\u590d\u6742\u5ea6\u5c31\u662f O(n) \u4e86\u54e6\u3002<\/p>\n\n\n\n<p>ok\uff0c\u4ee5\u4e0a\u4e3b\u8981\u8ba9\u4f60\u5148\u5bf9\u961f\u5217\u8fd9\u79cd\u6570\u636e\u7ed3\u6784\u6709\u4e00\u4e2a\u8ba4\u8bc6\uff0c\u63a5\u4e0b\u6765\u8fd8\u4f1a\u8fdb\u4e00\u6b65\u8bb2\u89e3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u961f\u5217 \u4f60\u5403\u5b8c\u4e1c\u897f\u540e\u6709\u5e8f\u62c9\u51fa\u6765\u7684\u8fc7\u7a0b\uff0c\u5c31\u662f\u961f\u5217\u3002 \u548c\u6808\u8fd9\u79cd\u6570\u636e\u7ed3\u6784\u4e0d\u540c\u7684\u662f\uff0c\u961f\u5217\u53ef\u4ee5\u5b58\u5165\u548c\u53d6\u51fa\u6570\u636e\uff0c\u4e0d\u8fc7\u5b83\u5177\u6709 \u201c\u5148\u8fdb\u5148\u51fa\u201d \u7684\u7279\u70b9\uff0c\u5b83\u6709\u4e24\u4e2a\u4e3b\u8981\u7684\u64cd\u4f5c\uff1a\u5165\u961f\u548c\u51fa\u961f\uff1a \u5176\u5b9e\u4f60\u5728\u751f\u6d3b\u8fc7\u7a0b\u4e2d\u5c31\u7ecf\u5e38\u9047\u5230 \u201c\u961f\u5217\u201d\uff0c\u6bd4\u5982\u4f60\u6392\u961f\u8fdb\u9ad8\u94c1\u68c0\u7968\u7684\u65f6\u5019\uff0c\u6392\u5728\u524d\u9762\u7684\u4eba\u5c31\u5148&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6105,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[475],"tags":[19,51,501],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6097"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6097"}],"version-history":[{"count":2,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6097\/revisions"}],"predecessor-version":[{"id":6109,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6097\/revisions\/6109"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/6105"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}