Skip to content

Commit 029abbc

Browse files
committed
Deployed f742626 with MkDocs version: 1.0.4
1 parent 0217508 commit 029abbc

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

19_python内置常用算法和数据结构/builtins/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ <h1 id="python">Python 刷题常用内置算法和数据结构</h1>
260260
<tbody>
261261
<tr>
262262
<td>线性结构</td>
263-
<td>list(列表)/tuple(元祖)</td>
263+
<td>list(列表)/tuple(元组)</td>
264264
<td>array(数组,不常用)/collections.namedtuple</td>
265265
</tr>
266266
<tr>
@@ -420,6 +420,7 @@ <h1 id="_3">内置库实现优先级队列的三种方式</h1>
420420
def test_buildin_heapq_as_PriorityQueue():
421421
&quot;&quot;&quot;
422422
测试使用 heapq 实现优先级队列,保存一个 tuple 比较元素(tuple第一个元素是优先级)
423+
实际上是利用了元组tuple比较从第一个开始比较的性质
423424
&quot;&quot;&quot;
424425
import heapq
425426
s_roll = []
@@ -437,15 +438,16 @@ <h1 id="_3">内置库实现优先级队列的三种方式</h1>
437438
def __init__(self, key, weight):
438439
self.key, self.weight = key, weight
439440

440-
def __lt__(self, other): # 看其来 heapq 实现只用了 小于 比较,这里定义了就可以 push 一个 item 类
441+
def __lt__(self, other): # heapq 源码实现只用了 小于 比较,这里定义了就可以 push 一个 item 类
441442
return self.weight &lt; other.weight
442443

443-
def __eq__(self, other):
444+
def __eq__(self, other): # 这个可以省略,只要定义了 __lt__ 魔法函数就可以了
444445
return self.weight == other.weight
445446

446447
def __str__(self):
447448
return '{}:{}'.format(self.key,self.weight)
448449

450+
# Item.__lt__ = lambda self, other: self.weight &lt; other.weight # 对于已有的类,直接加一句就可以实现作为 heap item 了
449451

450452
def test_heap_item():
451453
&quot;&quot;&quot;

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,5 +599,5 @@ <h2 id="_22">本电子书制作和写作方式</h2>
599599

600600
<!--
601601
MkDocs version : 1.0.4
602-
Build Date UTC : 2022-02-19 03:29:49
602+
Build Date UTC : 2022-02-19 08:43:39
603603
-->

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

sitemap.xml.gz

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)