diff --git a/docs/notes/Java 容器.md b/docs/notes/Java 容器.md index 2ef052a4..30121c35 100644 --- a/docs/notes/Java 容器.md +++ b/docs/notes/Java 容器.md @@ -26,7 +26,7 @@ ## Collection -

+

### 1. Set @@ -52,7 +52,7 @@ ## Map -

+

- TreeMap:基于红黑树实现。 @@ -67,7 +67,7 @@ ## 迭代器模式 -

+

Collection 继承了 Iterable 接口,其中的 iterator() 方法能够产生一个 Iterator 对象,通过这个对象就可以迭代遍历 Collection 中的元素。 @@ -112,6 +112,7 @@ List list = Arrays.asList(1, 2, 3); ## ArrayList + ### 1. 概览 实现了 RandomAccess 接口,因此支持随机访问。这是理所当然的,因为 ArrayList 是基于数组实现的。 @@ -127,6 +128,9 @@ public class ArrayList extends AbstractList private static final int DEFAULT_CAPACITY = 10; ``` +

+ + ### 2. 扩容 添加元素时使用 ensureCapacityInternal() 方法来保证容量足够,如果不够时,需要使用 grow() 方法进行扩容,新容量的大小为 `oldCapacity + (oldCapacity >> 1)`,也就是旧容量的 1.5 倍。 @@ -388,7 +392,7 @@ transient Node first; transient Node last; ``` -

+

### 2. 与 ArrayList 的比较 @@ -410,7 +414,7 @@ transient Entry[] table; Entry 存储着键值对。它包含了四个字段,从 next 字段我们可以看出 Entry 是一个链表。即数组中的每个位置被当成一个桶,一个桶存放一个链表。HashMap 使用拉链法来解决冲突,同一个链表中存放哈希值相同的 Entry。 -

+

```java static class Entry implements Map.Entry { @@ -486,7 +490,7 @@ map.put("K3", "V3"); - 计算键值对所在的桶; - 在链表上顺序查找,时间复杂度显然和链表的长度成正比。 -

+

### 3. put 操作 @@ -822,7 +826,7 @@ final Segment[] segments; static final int DEFAULT_CONCURRENCY_LEVEL = 16; ``` -

+

### 2. size 操作 diff --git a/docs/notes/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png b/docs/notes/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png new file mode 100644 index 00000000..17f4d5b7 Binary files /dev/null and b/docs/notes/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png differ diff --git a/docs/notes/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg b/docs/notes/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg new file mode 100644 index 00000000..a9effcf7 Binary files /dev/null and b/docs/notes/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg differ diff --git a/docs/notes/pics/20e61b68-effe-4a70-a7fd-58be23f9343a.png b/docs/notes/pics/20e61b68-effe-4a70-a7fd-58be23f9343a.png new file mode 100644 index 00000000..7da1a21f Binary files /dev/null and b/docs/notes/pics/20e61b68-effe-4a70-a7fd-58be23f9343a.png differ diff --git a/docs/notes/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png b/docs/notes/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png new file mode 100644 index 00000000..d146ec06 Binary files /dev/null and b/docs/notes/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png differ diff --git a/docs/notes/pics/938fc386-0340-47b5-aeaa-6993e3bb4fc0.png b/docs/notes/pics/938fc386-0340-47b5-aeaa-6993e3bb4fc0.png new file mode 100644 index 00000000..9064fe0e Binary files /dev/null and b/docs/notes/pics/938fc386-0340-47b5-aeaa-6993e3bb4fc0.png differ diff --git a/docs/notes/pics/c26e7ce3-dd9e-47e2-a208-367b5b2cddf6.png b/docs/notes/pics/c26e7ce3-dd9e-47e2-a208-367b5b2cddf6.png new file mode 100644 index 00000000..cf8d36dc Binary files /dev/null and b/docs/notes/pics/c26e7ce3-dd9e-47e2-a208-367b5b2cddf6.png differ diff --git a/docs/notes/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg b/docs/notes/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg new file mode 100644 index 00000000..b3699644 Binary files /dev/null and b/docs/notes/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg differ diff --git a/docs/notes/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg b/docs/notes/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg new file mode 100644 index 00000000..7746a715 Binary files /dev/null and b/docs/notes/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg differ diff --git a/docs/notes/剑指 offer 题解.md b/docs/notes/剑指 offer 题解.md index fd1c084e..ab457739 100644 --- a/docs/notes/剑指 offer 题解.md +++ b/docs/notes/剑指 offer 题解.md @@ -80,6 +80,8 @@ +部分绘图文件可以在这里免费下载:[剑指 Offer](https://www.processon.com/view/5a3e4c7be4b0909c1aa18b49),后续会慢慢把所有题目都配上 GIF 演示图。 + # 3. 数组中重复的数字 [NowCoder](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking) diff --git a/docs/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png b/docs/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png new file mode 100644 index 00000000..17f4d5b7 Binary files /dev/null and b/docs/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png differ diff --git a/docs/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg b/docs/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg new file mode 100644 index 00000000..a9effcf7 Binary files /dev/null and b/docs/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg differ diff --git a/docs/pics/20e61b68-effe-4a70-a7fd-58be23f9343a.png b/docs/pics/20e61b68-effe-4a70-a7fd-58be23f9343a.png new file mode 100644 index 00000000..7da1a21f Binary files /dev/null and b/docs/pics/20e61b68-effe-4a70-a7fd-58be23f9343a.png differ diff --git a/docs/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png b/docs/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png new file mode 100644 index 00000000..d146ec06 Binary files /dev/null and b/docs/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png differ diff --git a/docs/pics/938fc386-0340-47b5-aeaa-6993e3bb4fc0.png b/docs/pics/938fc386-0340-47b5-aeaa-6993e3bb4fc0.png new file mode 100644 index 00000000..9064fe0e Binary files /dev/null and b/docs/pics/938fc386-0340-47b5-aeaa-6993e3bb4fc0.png differ diff --git a/docs/pics/c26e7ce3-dd9e-47e2-a208-367b5b2cddf6.png b/docs/pics/c26e7ce3-dd9e-47e2-a208-367b5b2cddf6.png new file mode 100644 index 00000000..cf8d36dc Binary files /dev/null and b/docs/pics/c26e7ce3-dd9e-47e2-a208-367b5b2cddf6.png differ diff --git a/docs/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg b/docs/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg new file mode 100644 index 00000000..b3699644 Binary files /dev/null and b/docs/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg differ diff --git a/docs/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg b/docs/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg new file mode 100644 index 00000000..7746a715 Binary files /dev/null and b/docs/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg differ