File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 6
6
本教程是付费教程(文字内容和代码免费),因为笔者录制的过程中除了购买软件、手写板等硬件之外,业余需要花费很多时间和精力来录制视频、查资料、编写课件和代码,养家糊口不容易,希望大家体谅。
7
7
8
8
## 链接
9
+ 视频教程已经发布在网易云课堂和 csdn 学院,内容一致。
9
10
10
11
[ 网易云课堂: Python数据结构与算法教程] ( http://study.163.com/course/introduction.htm?courseId=1005526003 ) 视频教程
11
12
13
+ [ csdn 学院:Python数据结构与算法教程] ( https://edu.csdn.net/course/detail/8332 )
14
+
12
15
[ 网上阅读《Python 算法与数据结构教程 》] ( http://ningning.today/python_data_structures_and_algorithms/ )
13
16
14
17
[ github 链接] ( https://github.com/PegasusWang/python_data_structures_and_algorithms )
@@ -180,7 +183,7 @@ Python 抽象程度比较高, 我们能用更少的代码来实现功能,同
180
183
有出版社找过笔者想让我出书,一来自己对出书兴趣不大,另外感觉书籍相对视频不够直观,有错误也不能及时修改,打算直接把所有
181
184
文字内容讲义和代码等放到 github 上,供大家免费查阅。
182
185
183
- 如果你发现文字内容、代码内容或者视频内容有错误,欢迎在 github 上提 issue 讨论,或者直接提 Merge Request,我会修正相关内容,防止对读者产生误导(同时感谢认真学习并及时发现书中错误的同学 )。
186
+ 如果你发现文字内容、代码内容或者视频内容有错误,欢迎在 github 上提 issue 讨论,或者直接提 Merge Request,我会修正相关内容,防止对读者产生误导(同时非常感谢认真学习并及时发现书中错误的同学 )。
184
187
185
188
186
189
## 本电子书制作和写作方式
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def __init__(self, maxsize):
40
40
def push (self , value ):
41
41
if len (self ) >= self .maxsize :
42
42
raise FullError ('queue full' )
43
- self .array [self .head ] = value
43
+ self .array [self .head % self . maxsize ] = value
44
44
self .head += 1
45
45
46
46
def pop (self ):
@@ -49,7 +49,7 @@ def pop(self):
49
49
return value
50
50
51
51
def __len__ (self ):
52
- return self .head - self .tail
52
+ return self .head - self .tail
53
53
54
54
55
55
def test_queue ():
@@ -68,10 +68,13 @@ def test_queue():
68
68
assert q .pop () == 0
69
69
assert q .pop () == 1
70
70
71
- assert len (q ) == 3
71
+ q .push (5 )
72
+
73
+ assert len (q ) == 4
72
74
73
75
assert q .pop () == 2
74
76
assert q .pop () == 3
75
77
assert q .pop () == 4
78
+ assert q .pop () == 5
76
79
77
80
assert len (q ) == 0
You can’t perform that action at this time.
0 commit comments