{"id":859,"date":"2018-07-17T18:17:40","date_gmt":"2018-07-17T10:17:40","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=859"},"modified":"2018-07-17T18:17:40","modified_gmt":"2018-07-17T10:17:40","slug":"%e7%ac%ac%e5%8d%81%e4%b8%80%e8%ae%b2%ef%bc%9a%e9%98%9f%e5%88%97%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/python\/859\/","title":{"rendered":"\u7b2c\u5341\u4e00\u8bb2\uff1a\u961f\u5217\u7684\u5b9e\u73b0"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># -*- coding:utf-8 -*-\n# \u961f\u5217\u7684\u5b9e\u73b0\nclass Queue(object):\n    def __init__(self):\n        self.dataList = []\n    def initQueue(self):\n        self.dataList = []\n    def insert(self, data):\n        self.dataList.append(data)\n    def pop(self):\n        if len(self.dataList) == 0:\n            return None\n        data = self.dataList[0]\n        del self.dataList[0]  # \u5220\u9664\u5217\u8868\u4e2d\u7684\u5143\u7d20\n        return data\n    def size(self):\n        return len(self.dataList)\nqueue = Queue()\n# print queue.size()\nqueue.insert(1)\nqueue.insert(2)\nqueue.insert(3)\nhead = queue.pop()\n# print head\nhead = queue.pop()\n# print head\nhead = queue.pop()\n# print head\nhead = queue.pop()\n# print head\n# \u6808\u7684\u5b9e\u73b0\nclass Stack(object):\n    def __init__(self):\n        self.dataStack = []\n    def insert(self, data):\n        self.dataStack.append(data)\n    def pop(self):\n        if len(self.dataStack) == 0:\n            return None\n        data = self.dataStack[-1]       # \u7528-1 \u8bbf\u95ee\u5217\u8868\u4e2d\u6700\u540e\u4e00\u9879\n        del self.dataStack[-1]\n        return data\n    def size(self):\n        return len(self.dataStack)\nstack = Stack()\nstack.insert(1)\nstack.insert(2)\nstack.insert(3)\n# print stack.pop()\n# print stack.pop()\n# print stack.pop()\n# print stack.pop()\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p># -*- coding:utf-8 -*- # \u961f\u5217\u7684\u5b9e\u73b0 class Queue(object) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[24],"tags":[],"views":1833,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/859"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=859"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/859\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=859"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}