Skip to content

Commit 66f244b

Browse files
committed
Deployed 0c51b9a with MkDocs version: 0.17.3
1 parent 387c6ed commit 66f244b

21 files changed

+600
-588
lines changed
Binary file not shown.
Binary file not shown.
6.59 KB
Binary file not shown.
10.4 KB
Binary file not shown.
9.37 KB
Binary file not shown.

03_链表/linked_list.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def remove(self, value): # O(n)
7474
del curnode
7575
self.length -= 1
7676
return 1 # 表明删除成功
77+
else:
78+
prevnode = curnode
7779
return -1 # 表明删除失败
7880

7981
def find(self, value): # O(n)
@@ -113,26 +115,27 @@ def test_linked_list():
113115
ll.append(0)
114116
ll.append(1)
115117
ll.append(2)
118+
ll.append(3)
116119

117-
assert len(ll) == 3
120+
assert len(ll) == 4
118121
assert ll.find(2) == 2
119-
assert ll.find(3) == -1
122+
assert ll.find(-1) == -1
120123

121124
assert ll.remove(0) == 1
122-
assert ll.remove(3) == -1
125+
assert ll.remove(10) == -1
126+
assert ll.remove(2) == 1
123127
assert len(ll) == 2
128+
assert list(ll) == [1, 3]
124129
assert ll.find(0) == -1
125130

126-
assert list(ll) == [1, 2]
127-
128131
ll.appendleft(0)
129-
assert list(ll) == [0, 1, 2]
132+
assert list(ll) == [0, 1, 3]
130133
assert len(ll) == 3
131134

132135
headvalue = ll.popleft()
133136
assert headvalue == 0
134137
assert len(ll) == 2
135-
assert list(ll) == [1, 2]
138+
assert list(ll) == [1, 3]
136139

137140
ll.clear()
138141
assert len(ll) == 0

03_链表/wnntest.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# python linked_list.py
4+
when-changed . 'py.test -s linked_list.py'
5+
# when-changed . 'py.test -s double_link_list.py'
6+
# python double_link_list.py
5.6 KB
Binary file not shown.
3.83 KB
Binary file not shown.
6.74 KB
Binary file not shown.

0 commit comments

Comments
 (0)