{"id":2963,"date":"2023-07-14T16:47:57","date_gmt":"2023-07-14T08:47:57","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=2963"},"modified":"2023-07-14T16:47:58","modified_gmt":"2023-07-14T08:47:58","slug":"%e4%bc%98%e5%85%88%e9%98%9f%e5%88%97priorityqueue%ef%bc%8c%e6%9c%89%e7%a9%ba%e4%ba%86%e8%a7%a3%e4%b8%80%e4%b8%8b%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%98%9f%e5%88%97\/%e4%bc%98%e5%85%88%e9%98%9f%e5%88%97priorityqueue%ef%bc%8c%e6%9c%89%e7%a9%ba%e4%ba%86%e8%a7%a3%e4%b8%80%e4%b8%8b%e5%90%97%ef%bc%9f\/","title":{"rendered":"\u4f18\u5148\u961f\u5217PriorityQueue\uff0c\u6709\u7a7a\u4e86\u89e3\u4e00\u4e0b\u5417\uff1f"},"content":{"rendered":"<section data-tool=\"markdown\u7f16\u8f91\u5668\" data-website=\"https:\/\/markdown.com.cn\/editor\" style=\"font-size: 16px;color: black;padding: 25px 30px;line-height: 1.6;letter-spacing: 0px;word-break: break-word;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;margin-top: -10px;\">\n<h2 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 22px;line-height: 1.5em;margin-top: 2.2em;margin-bottom: 35px;\"><span style=\"display: none;\"><\/span><span style=\"display: inline-block;background-image: linear-gradient(rgb(255, 255, 255) 60%, rgb(255, 177, 27) 40%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;color: rgb(81, 81, 81);padding: 2px 13px;margin-right: 3px;height: 50%;\">\u524d\u8a00<\/span><\/h2>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\"><code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u8fd9\u4e2a\u961f\u5217\u4e0d\u77e5\u9053\u5927\u5bb6\u4f7f\u7528\u8fc7\u5417\uff0c\u53cd\u6b63\u6211\u7528\u7684\u5f88\u5c11\uff0c\u4e3b\u8981\u5bf9\u5b83\u4e0d\u662f\u5f88\u4e86\u89e3\uff0c\u4eca\u5929\u6211\u5e26\u9886\u5927\u5bb6\u5256\u6790\u4e0b<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u8fd9\u4e2a\u4f18\u5148\u7ea7\u961f\u5217\u3002<\/p>\n<h2 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 22px;line-height: 1.5em;margin-top: 2.2em;margin-bottom: 35px;\"><span style=\"display: none;\"><\/span><span style=\"display: inline-block;background-image: linear-gradient(rgb(255, 255, 255) 60%, rgb(255, 177, 27) 40%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;color: rgb(81, 81, 81);padding: 2px 13px;margin-right: 3px;height: 50%;\">PriorityQueue\u4ecb\u7ecd<\/span><\/h2>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u987e\u540d\u601d\u4e49\uff0c<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u662f\u4f18\u5148\u961f\u5217\u7684\u610f\u601d\u3002\u4f18\u5148\u961f\u5217\u7684\u4f5c\u7528\u662f\u80fd\u4fdd\u8bc1\u6bcf\u6b21\u53d6\u51fa\u7684\u5143\u7d20\u90fd\u662f\u961f\u5217\u4e2d\u6743\u503c\u6700\u5c0f\u7684\u3002\u8fd9\u91cc\u7275\u6d89\u5230\u4e86\u5927\u5c0f\u5173\u7cfb\uff0c\u5143\u7d20\u5927\u5c0f\u7684\u8bc4\u5224\u53ef\u4ee5\u901a\u8fc7\u5143\u7d20\u672c\u8eab\u7684\u81ea\u7136\u987a\u5e8f<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">\uff08natural ordering\uff09<\/code>\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u65f6\u4f20\u5165\u7684\u6bd4\u8f83\u5668\u3002<\/p>\n<ul data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    <code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u5b9e\u73b0\u4e86<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">Queue<\/code>\u63a5\u53e3\uff0c\u6700\u5927\u7684\u7279\u70b9\u662f\u5b58\u53d6\u5177\u6709\u4f18\u5148\u7ea7\uff0c\u5c31\u662f\u6839\u636e\u5143\u7d20\u7684\u987a\u5e8f\u6765\u51b3\u5b9a<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    <code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u662f\u4e00\u4e2a\u65e0\u754c\u7684\u5bb9\u5668<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    <code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u5e95\u5c42\u662f\u57fa\u4e8e\u5806\u5b9e\u73b0\u7684<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    \u4e0d\u5141\u8bb8\u653e\u5165<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">null<\/code>\u5143\u7d20<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    <code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u4e0d\u662f\u7ebf\u7a0b\u5b89\u5168\u7684<br \/>\n<\/section>\n<\/li>\n<\/ul>\n<figure data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\">\n  <img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.7074074074074074\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-type=\"png\" data-w=\"1080\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.7074074074074074\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png\" data-type=\"png\" data-w=\"1080\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><\/noscript><\/figure>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u4ee5\u4e0a\u662f<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u7684\u7c7b\u56fe,<\/p>\n<ul data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    \u7ee7\u627f\u4e86AbstractQueue\u62bd\u8c61\u7c7b\uff0c\u5b9e\u73b0\u4e86Queue\u63a5\u53e3\uff0c\u5177\u5907\u961f\u5217\u7684\u64cd\u4f5c\u65b9\u6cd5<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    \u5b9e\u73b0\u4e86Seriablizable\u63a5\u53e3\uff0c\u652f\u6301\u5e8f\u5217\u5316<br \/>\n<\/section>\n<\/li>\n<\/ul>\n<h3 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 20px;line-height: 1.4;padding-top: 10px;margin-top: 10px;margin-bottom: 5px;\"><span style=\"display: none;\"><\/span><span style=\"color: rgb(81, 81, 81);font-size: 1em;padding-left: 20px;border-left: 3px solid rgb(249, 191, 69);\">\u6784\u9020\u65b9\u6cd5<\/span><span style=\"display: none;\"><\/span><\/h3>\n<table data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\">\n<thead>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<th style=\"border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);text-align: center;\"><strong>\u65b9\u6cd5<\/strong><\/th>\n<th style=\"border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);text-align: center;\"><strong>\u8bf4\u660e<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody style=\"border-width: 0px;border-style: initial;border-color: initial;\">\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">PriorityQueue()<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u6784\u9020\u4e00\u4e2a\u521d\u59cb\u5bb9\u91cf\u4e3a11\u7684\u4f18\u5148\u961f\u5217<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">PriorityQueue(Comparator&lt;? super E&gt; comparator)<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u6784\u9020\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6392\u5e8f\u5668\u7684\u4f18\u5148\u961f\u5217<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">PriorityQueue(SortedSet&lt;? extends E&gt; c)<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u6784\u9020\u4e00\u4e2a\u57fa\u4e8eSortedSet\u5185\u5bb9\u7684\u4f18\u5148\u961f\u5217<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 20px;line-height: 1.4;padding-top: 10px;margin-top: 10px;margin-bottom: 5px;\"><span style=\"display: none;\"><\/span><span style=\"color: rgb(81, 81, 81);font-size: 1em;padding-left: 20px;border-left: 3px solid rgb(249, 191, 69);\">\u5173\u952e\u65b9\u6cd5<\/span><span style=\"display: none;\"><\/span><\/h3>\n<table data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\">\n<thead>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<th style=\"border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);text-align: center;\"><strong>\u65b9\u6cd5<\/strong><\/th>\n<th style=\"border-top-width: 1px;border-color: rgb(204, 204, 204);background-color: rgb(240, 240, 240);text-align: center;\"><strong>\u8bf4\u660e<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody style=\"border-width: 0px;border-style: initial;border-color: initial;\">\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">add(E e)<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u6dfb\u52a0\u5143\u7d20\uff0c\u5982\u679c\u8d85\u8fc7\u961f\u5217\u957f\u5ea6\uff0c\u629b\u51fa\u5f02\u5e38<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">offer(E e)<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u6dfb\u52a0\u5143\u7d20\uff0c\u5982\u679c\u8d85\u8fc7\u961f\u5217\u957f\u5ea6\u8fd4\u56defalse<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">remove()<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u83b7\u53d6\u4e0b\u4e2a\u5143\u7d20\uff0c\u5982\u679c\u6ca1\u6709\u629b\u51fa\u5f02\u5e38<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">poll()<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u83b7\u53d6\u4e0b\u4e2a\u5143\u7d20\uff0c\u5982\u679c\u6ca1\u6709\u8fd4\u56denull<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: white;\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">element()<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u67e5\u770b\u4e0b\u4e2a\u5143\u7d20\u7684\u5185\u5bb9\uff0c\u5982\u679c\u6ca1\u6709\u629b\u5f02\u5e38<\/td>\n<\/tr>\n<tr style=\"border-width: 1px 0px 0px;border-right-style: initial;border-bottom-style: initial;border-left-style: initial;border-right-color: initial;border-bottom-color: initial;border-left-color: initial;border-top-style: solid;border-top-color: rgb(204, 204, 204);background-color: rgb(248, 248, 248);\">\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">peek()<\/td>\n<td style=\"border-color: rgb(204, 204, 204);text-align: center;\">\u67e5\u770b\u4e0b\u4e2a\u5143\u7d20\u7684\u5185\u5bb9\uff0c\u5982\u679c\u6ca1\u6709\u8fd4\u56denull<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 22px;line-height: 1.5em;margin-top: 2.2em;margin-bottom: 35px;\"><span style=\"display: none;\"><\/span><span style=\"display: inline-block;background-image: linear-gradient(rgb(255, 255, 255) 60%, rgb(255, 177, 27) 40%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;color: rgb(81, 81, 81);padding: 2px 13px;margin-right: 3px;height: 50%;\">\u4f7f\u7528\u6848\u4f8b<\/span><\/h2>\n<ol data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    \u4f18\u5148\u961f\u5217\u529f\u80fd\u6d4b\u8bd5<br \/>\n<\/section>\n<\/li>\n<\/ol>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"color: #999;font-weight: bold;line-height: 26px;\">@Test<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">public<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">void<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">test1<\/span><span style=\"line-height: 26px;\">()<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queue&lt;Integer&gt;&nbsp;queue&nbsp;=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">new<\/span>&nbsp;PriorityQueue&lt;&gt;();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">5<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">4<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">1<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">9<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">3<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">2<\/span>);\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u6253\u5370\uff0c\u6392\u5e8f<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Integer&nbsp;poll&nbsp;=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">null<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">while<\/span>&nbsp;((poll&nbsp;=&nbsp;queue.poll())&nbsp;!=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">null<\/span>)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(poll);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<figure data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\">\n  <img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.9456066945606695\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/20230714164715eded07252.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-type=\"png\" data-w=\"478\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.9456066945606695\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/20230714164715eded07252.png\" data-type=\"png\" data-w=\"478\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><\/noscript><\/figure>\n<ol start=\"2\" data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    \u81ea\u5b9a\u4e49\u6392\u5e8f\u5668<br \/>\n<\/section>\n<\/li>\n<\/ol>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"color: #999;font-weight: bold;line-height: 26px;\">@Test<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">public<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">void<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">test2<\/span><span style=\"line-height: 26px;\">()<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u81ea\u5b9a\u4e49\u6392\u5e8f\uff0c\u5012\u5e8f<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queue&lt;Integer&gt;&nbsp;queue&nbsp;=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">new<\/span>&nbsp;PriorityQueue&lt;&gt;(Collections.reverseOrder());\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">5<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">4<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">1<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">9<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">3<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.offer(<span style=\"color: #008080;line-height: 26px;\">2<\/span>);\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u6253\u5370\uff0c\u6392\u5e8f<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Integer&nbsp;poll&nbsp;=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">null<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">while<\/span>&nbsp;((poll&nbsp;=&nbsp;queue.poll())&nbsp;!=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">null<\/span>)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(poll);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<figure data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\">\n  <img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.8409090909090909\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/2023071416471581818d970.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-type=\"png\" data-w=\"528\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.8409090909090909\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/2023071416471581818d970.png\" data-type=\"png\" data-w=\"528\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><\/noscript><\/figure>\n<h2 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 22px;line-height: 1.5em;margin-top: 2.2em;margin-bottom: 35px;\"><span style=\"display: none;\"><\/span><span style=\"display: inline-block;background-image: linear-gradient(rgb(255, 255, 255) 60%, rgb(255, 177, 27) 40%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;color: rgb(81, 81, 81);padding: 2px 13px;margin-right: 3px;height: 50%;\">\u5b9e\u73b0\u673a\u5236<\/span><\/h2>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\"><code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u901a\u8fc7\u5806\u5b9e\u73b0\uff0c\u5177\u4f53\u8bf4\u662f\u901a\u8fc7\u5b8c\u5168\u4e8c\u53c9\u6811\uff08<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">complete binary tree<\/code>\uff09\u5b9e\u73b0\u7684\u5c0f\u9876\u5806\uff08\u4efb\u610f\u4e00\u4e2a\u975e\u53f6\u5b50\u8282\u70b9\u7684\u6743\u503c\uff0c\u90fd\u4e0d\u5927\u4e8e\u5176\u5de6\u53f3\u5b50\u8282\u70b9\u7684\u6743\u503c\uff09\uff0c\u4e5f\u5c31\u610f\u5473\u7740\u53ef\u4ee5\u901a\u8fc7\u6570\u7ec4\u6765\u4f5c\u4e3a<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">PriorityQueue<\/code>\u7684\u5e95\u5c42\u5b9e\u73b0\u3002<\/p>\n<figure data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\">\n  <img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.9064814814814814\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/202307141647157c7ce1c20.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-type=\"png\" data-w=\"1080\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.9064814814814814\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/202307141647157c7ce1c20.png\" data-type=\"png\" data-w=\"1080\" style=\"margin-right: auto;margin-left: auto;width: 100%;border-radius: 5px;display: block;margin-bottom: 15px;\"><\/noscript><\/figure>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u4e0a\u56fe\u4e2d\u6211\u4eec\u7ed9\u6bcf\u4e2a\u5143\u7d20\u6309\u7167\u5c42\u5e8f\u904d\u5386\u7684\u65b9\u5f0f\u8fdb\u884c\u4e86\u7f16\u53f7\uff0c\u5982\u679c\u4f60\u8db3\u591f\u7ec6\u5fc3\uff0c\u4f1a\u53d1\u73b0\u7236\u8282\u70b9\u548c\u5b50\u8282\u70b9\u7684\u7f16\u53f7\u662f\u6709\u8054\u7cfb\u7684\uff0c\u66f4\u786e\u5207\u7684\u8bf4\u7236\u5b50\u8282\u70b9\u7684\u7f16\u53f7\u4e4b\u95f4\u6709\u5982\u4e0b\u5173\u7cfb\uff1a<\/p>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\"><code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">leftNo = parentNo*2+1<\/code><\/p>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\"><code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">rightNo = parentNo*2+2<\/code><\/p>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\"><code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">parentNo = (nodeNo-1)\/2<\/code><\/p>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u901a\u8fc7\u4e0a\u8ff0\u4e09\u4e2a\u516c\u5f0f\uff0c\u53ef\u4ee5\u8f7b\u6613\u8ba1\u7b97\u51fa\u67d0\u4e2a\u8282\u70b9\u7684\u7236\u8282\u70b9\u4ee5\u53ca\u5b50\u8282\u70b9\u7684\u4e0b\u6807\u3002\u8fd9\u4e5f\u5c31\u662f\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u76f4\u63a5\u7528\u6570\u7ec4\u6765\u5b58\u50a8\u5806\u7684\u539f\u56e0\u3002<\/p>\n<h2 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 22px;line-height: 1.5em;margin-top: 2.2em;margin-bottom: 35px;\"><span style=\"display: none;\"><\/span><span style=\"display: inline-block;background-image: linear-gradient(rgb(255, 255, 255) 60%, rgb(255, 177, 27) 40%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;color: rgb(81, 81, 81);padding: 2px 13px;margin-right: 3px;height: 50%;\">\u6e90\u7801\u89e3\u6790<\/span><\/h2>\n<h3 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 20px;line-height: 1.4;padding-top: 10px;margin-top: 10px;margin-bottom: 5px;\"><span style=\"display: none;\"><\/span><span style=\"color: rgb(81, 81, 81);font-size: 1em;padding-left: 20px;border-left: 3px solid rgb(249, 191, 69);\">\u6210\u5458\u53d8\u91cf<\/span><span style=\"display: none;\"><\/span><\/h3>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"font-weight: bold;line-height: 26px;\">transient<\/span>&nbsp;Object[]&nbsp;queue;\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;number&nbsp;of&nbsp;elements&nbsp;in&nbsp;the&nbsp;priority&nbsp;queue.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n<span style=\"font-weight: bold;line-height: 26px;\">private<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;size&nbsp;=&nbsp;<span style=\"color: #008080;line-height: 26px;\">0<\/span>;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;comparator,&nbsp;or&nbsp;null&nbsp;if&nbsp;priority&nbsp;queue&nbsp;uses&nbsp;elements'\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;natural&nbsp;ordering.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n<span style=\"font-weight: bold;line-height: 26px;\">private<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">final<\/span>&nbsp;Comparator&lt;?&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">super<\/span>&nbsp;E&gt;&nbsp;comparator;\n\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/**\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;number&nbsp;of&nbsp;times&nbsp;this&nbsp;priority&nbsp;queue&nbsp;has&nbsp;been\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&lt;i&gt;structurally&nbsp;modified&lt;\/i&gt;.&nbsp;&nbsp;See&nbsp;AbstractList&nbsp;for&nbsp;gory&nbsp;details.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/span>\n<span style=\"font-weight: bold;line-height: 26px;\">transient<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;modCount&nbsp;=&nbsp;<span style=\"color: #008080;line-height: 26px;\">0<\/span>;\n<\/code><\/pre>\n<ul data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    queue\u5c31\u662f\u5b9e\u9645\u5b58\u50a8\u5143\u7d20\u7684\u6570\u7ec4\u3002<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    size\u8868\u793a\u5f53\u524d\u5143\u7d20\u4e2a\u6570\u3002<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    comparator\u4e3a\u6bd4\u8f83\u5668\uff0c\u53ef\u4ee5\u4e3anull\u3002<br \/>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    modCount\u8bb0\u5f55\u4fee\u6539\u6b21\u6570\u3002<br \/>\n<\/section>\n<\/li>\n<\/ul>\n<h3 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 20px;line-height: 1.4;padding-top: 10px;margin-top: 10px;margin-bottom: 5px;\"><span style=\"display: none;\"><\/span><span style=\"color: rgb(81, 81, 81);font-size: 1em;padding-left: 20px;border-left: 3px solid rgb(249, 191, 69);\">\u6784\u9020\u65b9\u6cd5<\/span><span style=\"display: none;\"><\/span><\/h3>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">public<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">PriorityQueue<\/span><span style=\"line-height: 26px;\">(<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;initialCapacity,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comparator&lt;?&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">super<\/span>&nbsp;E&gt;&nbsp;comparator)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;Note:&nbsp;This&nbsp;restriction&nbsp;of&nbsp;at&nbsp;least&nbsp;one&nbsp;is&nbsp;not&nbsp;actually&nbsp;needed,<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;but&nbsp;continues&nbsp;for&nbsp;1.5&nbsp;compatibility<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(initialCapacity&nbsp;&lt;&nbsp;<span style=\"color: #008080;line-height: 26px;\">1<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">throw<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">new<\/span>&nbsp;IllegalArgumentException();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">this<\/span>.queue&nbsp;=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">new<\/span>&nbsp;Object[initialCapacity];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">this<\/span>.comparator&nbsp;=&nbsp;comparator;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre>\n<ul data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;text-align: left;color: rgb(1, 1, 1);\">\n    \u521d\u59cb\u5316\u4e86queue\u548ccomparator<br \/>\n<\/section>\n<\/li>\n<\/ul>\n<h3 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 20px;line-height: 1.4;padding-top: 10px;margin-top: 10px;margin-bottom: 5px;\"><span style=\"display: none;\"><\/span><span style=\"color: rgb(81, 81, 81);font-size: 1em;padding-left: 20px;border-left: 3px solid rgb(249, 191, 69);\">\u6dfb\u52a0\u5143\u7d20offer<\/span><span style=\"display: none;\"><\/span><\/h3>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">public<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">boolean<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">offer<\/span><span style=\"line-height: 26px;\">(E&nbsp;e)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u5982\u679c\u5143\u7d20\u4e3a\u7a7a\uff0c\u629b\u51fa\u7a7a\u6307\u9488<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(e&nbsp;==&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">null<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">throw<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">new<\/span>&nbsp;NullPointerException();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u4fee\u6539\u6b21\u6570+1<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modCount++;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;i&nbsp;=&nbsp;size;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u9996\u5148\u786e\u4fdd\u6570\u7ec4\u957f\u5ea6\u662f\u591f\u7684\uff0c\u5982\u679c\u4e0d\u591f\uff0c\u8c03\u7528grow\u65b9\u6cd5\u52a8\u6001\u6269\u5c55\u3002<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(i&nbsp;&gt;=&nbsp;queue.length)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;grow(i&nbsp;+&nbsp;<span style=\"color: #008080;line-height: 26px;\">1<\/span>);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;=&nbsp;i&nbsp;+&nbsp;<span style=\"color: #008080;line-height: 26px;\">1<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u5982\u679c\u662f\u7b2c\u4e00\u6b21\u6dfb\u52a0\uff0c\u76f4\u63a5\u6dfb\u52a0\u5230\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u5373\u53ef&nbsp;(queue[0]=e)<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(i&nbsp;==&nbsp;<span style=\"color: #008080;line-height: 26px;\">0<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue[<span style=\"color: #008080;line-height: 26px;\">0<\/span>]&nbsp;=&nbsp;e;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">else<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u5426\u5219\u5c06\u5176\u653e\u5165\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u4f46\u540c\u65f6\u5411\u4e0a\u8c03\u6574\uff0c\u76f4\u81f3\u6ee1\u8db3\u5806\u7684\u6027\u8d28&nbsp;(siftUp)&nbsp;<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;siftUp(i,&nbsp;e);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">return<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">true<\/span>;\n}\n<\/code><\/pre>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">private<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">void<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">grow<\/span><span style=\"line-height: 26px;\">(<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;minCapacity)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;oldCapacity&nbsp;=&nbsp;queue.length;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;Double&nbsp;size&nbsp;if&nbsp;small;&nbsp;else&nbsp;grow&nbsp;by&nbsp;50%<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;newCapacity&nbsp;=&nbsp;oldCapacity&nbsp;+&nbsp;((oldCapacity&nbsp;&lt;&nbsp;<span style=\"color: #008080;line-height: 26px;\">64<\/span>)&nbsp;?\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(oldCapacity&nbsp;+&nbsp;<span style=\"color: #008080;line-height: 26px;\">2<\/span>)&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(oldCapacity&nbsp;&gt;&gt;&nbsp;<span style=\"color: #008080;line-height: 26px;\">1<\/span>));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;overflow-conscious&nbsp;code<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(newCapacity&nbsp;-&nbsp;MAX_ARRAY_SIZE&nbsp;&gt;&nbsp;<span style=\"color: #008080;line-height: 26px;\">0<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newCapacity&nbsp;=&nbsp;hugeCapacity(minCapacity);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue&nbsp;=&nbsp;Arrays.copyOf(queue,&nbsp;newCapacity);\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u5982\u679c\u539f\u957f\u5ea6\u6bd4\u8f83\u5c0f\uff0c\u5927\u6982\u5c31\u662f\u6269\u5c55\u4e3a\u4e24\u500d\uff0c\u5426\u5219\u5c31\u662f\u589e\u52a050%\uff0c\u4f7f\u7528Arrays.copyOf\u65b9\u6cd5\u62f7\u8d1d\u6570\u7ec4\u3002<\/p>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">private<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">void<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">siftUp<\/span><span style=\"line-height: 26px;\">(<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;k,&nbsp;E&nbsp;x)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #998;font-style: italic;line-height: 26px;\">\/\/&nbsp;\u5982\u679c\u6bd4\u8f83\u5668\u4e3a\u7a7a<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(comparator&nbsp;!=&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">null<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;siftUpUsingComparator(k,&nbsp;x);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">else<\/span>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;siftUpComparable(k,&nbsp;x);\n&nbsp;&nbsp;&nbsp;&nbsp;}\n<\/code><\/pre>\n<pre data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #333;background: #f8f8f8;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;border-radius: 0px;font-size: 12px;-webkit-overflow-scrolling: touch;\"><span style=\"line-height: 26px;\"><span style=\"font-weight: bold;line-height: 26px;\">private<\/span>&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">void<\/span>&nbsp;<span style=\"color: #900;font-weight: bold;line-height: 26px;\">siftUpUsingComparator<\/span><span style=\"line-height: 26px;\">(<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;k,&nbsp;E&nbsp;x)<\/span>&nbsp;<\/span>{\n&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">while<\/span>&nbsp;(k&nbsp;&gt;&nbsp;<span style=\"color: #008080;line-height: 26px;\">0<\/span>)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">int<\/span>&nbsp;parent&nbsp;=&nbsp;(k&nbsp;-&nbsp;<span style=\"color: #008080;line-height: 26px;\">1<\/span>)&nbsp;&gt;&gt;&gt;&nbsp;<span style=\"color: #008080;line-height: 26px;\">1<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Object&nbsp;e&nbsp;=&nbsp;queue[parent];\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">if<\/span>&nbsp;(comparator.compare(x,&nbsp;(E)&nbsp;e)&nbsp;&gt;=&nbsp;<span style=\"color: #008080;line-height: 26px;\">0<\/span>)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-weight: bold;line-height: 26px;\">break<\/span>;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue[k]&nbsp;=&nbsp;e;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k&nbsp;=&nbsp;parent;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;queue[k]&nbsp;=&nbsp;x;\n}\n<\/code><\/pre>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u53c2\u6570k\u8868\u793a\u63d2\u5165\u4f4d\u7f6e\uff0cx\u8868\u793a\u65b0\u5143\u7d20\u3002k\u521d\u59cb\u7b49\u4e8e\u6570\u7ec4\u5927\u5c0f\uff0c\u5373\u5728\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u63d2\u5165\u3002\u4ee3\u7801\u7684\u4e3b\u8981\u90e8\u5206\u662f\uff1a\u5f80\u4e0a\u5bfb\u627ex\u771f\u6b63\u5e94\u8be5\u63d2\u5165\u7684\u4f4d\u7f6e\uff0c\u8fd9\u4e2a\u4f4d\u7f6e\u7528k\u8868\u793a\u3002<\/p>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u600e\u4e48\u627e\u5462\uff1f\u65b0\u5143\u7d20(x)\u4e0d\u65ad\u4e0e\u7236\u8282\u70b9(e)\u6bd4\u8f83\uff0c\u5982\u679c\u65b0\u5143\u7d20(x)\u5927\u4e8e\u7b49\u4e8e\u7236\u8282\u70b9(e)\uff0c\u5219\u5df2\u6ee1\u8db3\u5806\u7684\u6027\u8d28\uff0c\u9000\u51fa\u5faa\u73af\uff0ck\u5c31\u662f\u65b0\u5143\u7d20\u6700\u7ec8\u7684\u4f4d\u7f6e\uff0c\u5426\u5219\uff0c\u5c06\u7236\u8282\u70b9\u5f80\u4e0b\u79fb(queue[k]=e)\uff0c\u7ee7\u7eed\u5411\u4e0a\u5bfb\u627e\u3002<\/p>\n<h2 data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"font-weight: bold;font-size: 22px;line-height: 1.5em;margin-top: 2.2em;margin-bottom: 35px;\"><span style=\"display: none;\"><\/span><span style=\"display: inline-block;background-image: linear-gradient(rgb(255, 255, 255) 60%, rgb(255, 177, 27) 40%);background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;color: rgb(81, 81, 81);padding: 2px 13px;margin-right: 3px;height: 50%;\">\u603b\u7ed3<\/span><\/h2>\n<p data-tool=\"markdown.com.cn\u7f16\u8f91\u5668\" style=\"margin-bottom: 20px;line-height: 1.8em;color: rgb(58, 58, 58);\">\u4f18\u5148\u7ea7\u53ef\u4ee5\u6709\u76f8\u540c\u7684\uff0c\u5185\u90e8\u5143\u7d20\u4e0d\u662f\u5b8c\u5168\u6709\u5e8f\u7684\uff0c\u5982\u679c\u904d\u5386\u8f93\u51fa\uff0c\u9664\u4e86\u7b2c\u4e00\u4e2a\uff0c\u5176\u4ed6\u6ca1\u6709\u7279\u5b9a\u987a\u5e8f\u3002\u67e5\u770b\u5934\u90e8\u5143\u7d20\u7684\u6548\u7387\u5f88\u9ad8\uff0c\u4e3a<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">O(1)<\/code>\uff0c\u5165\u961f\u3001\u51fa\u961f\u6548\u7387\u6bd4\u8f83\u9ad8\uff0c\u4e3a<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">O(log2(N))<\/code>\uff0c\u6784\u5efa\u5806\u7684\u6548\u7387\u4e3a<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">O(N)<\/code>\u3002\u6839\u636e\u503c\u67e5\u627e\u548c\u5220\u9664\u5143\u7d20\u7684\u6548\u7387\u6bd4\u8f83\u4f4e\uff0c\u4e3a<code style=\"font-size: 14px;border-radius: 4px;font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(155, 110, 35);background-color: rgb(255, 245, 227);padding: 3px;margin: 3px;\">O(N)<\/code>\u3002<\/p>\n<\/section>\n<p style=\"display: none;\">\n <mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7\uff1ahttps:\/\/mp.weixin.qq.com\/s\/Rjtum3oeCHwAdnXQszX1HA<\/p>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 PriorityQueue\u8fd9\u4e2a\u961f\u5217\u4e0d\u77e5\u9053\u5927\u5bb6\u4f7f\u7528\u8fc7\u5417\uff0c\u53cd\u6b63\u6211\u7528\u7684\u5f88\u5c11\uff0c\u4e3b\u8981\u5bf9\u5b83\u4e0d\u662f\u5f88\u4e86\u89e3\uff0c\u4eca\u5929\u6211\u5e26\u9886\u5927\u5bb6\u5256\u6790\u4e0bPriorit &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[34],"tags":[],"class_list":["post-2963","post","type-post","status-publish","format-standard","hentry","category-34"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-13\/202307141647137c7c1acfe.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/20230714164715eded07252.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/20230714164715eded07252.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/2023071416471581818d970.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/2023071416471581818d970.png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/202307141647157c7ce1c20.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/default\/nine\/2023-07-14\/16-47-15\/202307141647157c7ce1c20.png","id":"image7"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"\u961f\u5217","post_date":"2023-07-14","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":322,"next_post_id":3316,"next_post_title":"springboot kafka \u5b9e\u73b0\u5ef6\u65f6\u961f\u5217","previous_post_id":null,"previous_post_title":null,"_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/2963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2963"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/2963\/revisions"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}