Skip to content

Commit 4347aa7

Browse files
committed
Deployed 6e92cf5 with MkDocs version: 0.17.3
1 parent 823555a commit 4347aa7

21 files changed

+141
-54
lines changed

.DS_Store

6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
6.68 KB
Binary file not shown.
-3.8 KB
Binary file not shown.
9.67 KB
Binary file not shown.

03_链表/linked_list.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ def append(self, value): # O(1)
4545
def appendleft(self, value):
4646
if self.maxsize is not None and len(self) >= self.maxsize:
4747
raise Exception('LinkedList is Full')
48-
headnode = self.root.next
4948
node = Node(value)
49+
if self.tailnode is None: # 如果原链表为空,插入第一个元素需要设置 tailnode
50+
self.tailnode = node
51+
52+
headnode = self.root.next
5053
self.root.next = node
5154
node.next = headnode
5255
self.length += 1
@@ -166,6 +169,13 @@ def test_linked_list_remove():
166169
ll.remove(7)
167170
print(list(ll))
168171

172+
def test_linked_list_append():
173+
ll = LinkedList()
174+
ll.appendleft(1)
175+
ll.append(2)
176+
assert list(ll) == [1, 2]
177+
169178

170179
if __name__ == '__main__':
171180
test_linked_list()
181+
test_linked_list_append()

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.

0 commit comments

Comments
 (0)