auto commit

This commit is contained in:
CyC2018 2019-02-20 00:04:17 +08:00
parent 0cbc306a70
commit fca155be73
2 changed files with 14 additions and 4 deletions

View File

@ -222,6 +222,7 @@ obj = null;
<div align="center"> <img src="pics/3_2001550547558008.png"/> </div><br>
标记要回收的对象,然后清除。
不足:
@ -231,8 +232,10 @@ obj = null;
### 2. 标记 - 整理
<div align="center"> <img src="pics/2_2001550547456403.png"/> </div><br>
让所有存活的对象都向一端移动,然后直接清理掉端边界以外的内存。
### 3. 复制

View File

@ -967,6 +967,8 @@ private void printNumber(char[] number) {
<div align="center"> <img src="pics/27ff9548-edb6-4465-92c8-7e6386e0b185.png" width="600"/> </div><br>
② 如果链表只有一个节点,那么直接
② 否则,就需要先遍历链表,找到节点的前一个节点,然后让前一个节点指向 null时间复杂度为 O(N)。
<div align="center"> <img src="pics/280f7728-594f-4811-a03a-fa8d32c013da.png" width="600"/> </div><br>
@ -983,10 +985,15 @@ public ListNode deleteNode(ListNode head, ListNode tobeDelete) {
tobeDelete.val = next.val;
tobeDelete.next = next.next;
} else {
ListNode cur = head;
while (cur.next != tobeDelete)
cur = cur.next;
cur.next = null;
if (head == tobeDelete)
// 只有一个节点
head = null;
else {
ListNode cur = head;
while (cur.next != tobeDelete)
cur = cur.next;
cur.next = null;
}
}
return head;
}