auto commit
|
@ -20,12 +20,11 @@
|
|||
|
||||
# 一、概览
|
||||
|
||||
|
||||
容器主要包括 Collection 和 Map 两种,Collection 存储着对象的集合,而 Map 存储着键值对(两个对象)的映射表。
|
||||
|
||||
## Collection
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/6_2001550476096035.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/862d5e07-ff6e-4c0d-abe4-08488cbf8049_200.png" width="800px"> </div><br>
|
||||
|
||||
### 1. Set
|
||||
|
||||
|
@ -51,7 +50,8 @@
|
|||
|
||||
## Map
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/2_2001550426232419.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/8c001caa-cf3d-4793-a64e-6e7dbc446c0d_200.png" width="500px"> </div><br>
|
||||
|
||||
|
||||
- TreeMap:基于红黑树实现。
|
||||
|
||||
|
@ -66,7 +66,8 @@
|
|||
|
||||
## 迭代器模式
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/91aa7c29-438f-4fcc-8c63-2a75899139de.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/d0c1f611-3bc3-446d-8c0b-1b442b0ae8c91_200.png" width="600px"> </div><br>
|
||||
|
||||
|
||||
Collection 继承了 Iterable 接口,其中的 iterator() 方法能够产生一个 Iterator 对象,通过这个对象就可以迭代遍历 Collection 中的元素。
|
||||
|
||||
|
@ -127,8 +128,7 @@ public class ArrayList<E> extends AbstractList<E>
|
|||
private static final int DEFAULT_CAPACITY = 10;
|
||||
```
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/7935be3d-c2b3-4213-90c9-1e68ec4ac4e7.png"/> </div><br>
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/7c5e4fbe-8aab-4dd6-a7a0-aae39bfd110f_200.png" width="400px"> </div><br>
|
||||
|
||||
### 2. 扩容
|
||||
|
||||
|
@ -391,7 +391,7 @@ transient Node<E> first;
|
|||
transient Node<E> last;
|
||||
```
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/09184175-9bf2-40ff-8a68-3b467c77216a.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/a79aec4f-aea4-4ee2-87e3-7c7c6049b90c_200.png" width="400px"> </div><br>
|
||||
|
||||
### 2. 与 ArrayList 的比较
|
||||
|
||||
|
@ -413,7 +413,7 @@ transient Entry[] table;
|
|||
|
||||
Entry 存储着键值对。它包含了四个字段,从 next 字段我们可以看出 Entry 是一个链表。即数组中的每个位置被当成一个桶,一个桶存放一个链表。HashMap 使用拉链法来解决冲突,同一个链表中存放哈希值相同的 Entry。
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/1d2719d5-8d60-4c9b-a4ad-b2df7c7615af.jpg"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/9ccb276e-6840-4150-ae6d-fc57b8eef35b_200.png" width="500px"> </div><br>
|
||||
|
||||
```java
|
||||
static class Entry<K,V> implements Map.Entry<K,V> {
|
||||
|
@ -489,7 +489,7 @@ map.put("K3", "V3");
|
|||
- 计算键值对所在的桶;
|
||||
- 在链表上顺序查找,时间复杂度显然和链表的长度成正比。
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/cf779e26-0382-4495-8463-f1e19e2e38a0.jpg"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/ff98a336-a390-4d1c-adea-0a49e72fad82_200.png" width="500px"> </div><br>
|
||||
|
||||
### 3. put 操作
|
||||
|
||||
|
@ -825,7 +825,7 @@ final Segment<K,V>[] segments;
|
|||
static final int DEFAULT_CONCURRENCY_LEVEL = 16;
|
||||
```
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/deb18bdb-b3b3-4660-b778-b0823a48db12.jpg"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/d546e754-a5b2-4132-be09-b991f163884b_200.png" width="500px"> </div><br>
|
||||
|
||||
### 2. size 操作
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ BIOS 不可以读取 GPT 分区表,而 UEFI 可以。
|
|||
|
||||
对于 Ext2 文件系统,当要读取一个文件的内容时,先在 inode 中去查找文件内容所在的所有 block,然后把所有 block 的内容读出来。
|
||||
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/18c1ea05-bc12-4d1f-9179-76fda03cfa80_200.png"/> </div><br>
|
||||
<div align="center"> <img src="https://gitee.com/CyC2018/CS-Notes/raw/master/docs/pics/2f683fe8-bee8-46a9-86a7-685c8981555856191616.png"/> </div><br>
|
||||
|
||||
而对于 FAT 文件系统,它没有 inode,每个 block 中存储着下一个 block 的编号。
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ options 参数主要有 WNOHANG 和 WUNTRACED 两个选项,WNOHANG 可以使 w
|
|||
|
||||
系统所能使用的进程号是有限的,如果产生大量僵尸进程,将因为没有可用的进程号而导致系统不能产生新的进程。
|
||||
|
||||
要消灭系统中大量的僵尸进程,只需要将其父进程杀死,此时僵尸进程就会变成孤儿进程,从而被 init 所收养,这样 init 就会释放所有的僵尸进程所占有的资源,从而结束僵尸进程。
|
||||
要消灭系统中大量的僵尸进程,只需要将其父进程杀死,此时僵尸进程就会变成孤儿进程,从而被 init 进程所收养,这样 init 进程就会释放所有的僵尸进程所占有的资源,从而结束僵尸进程。
|
||||
|
||||
# 参考资料
|
||||
|
||||
|
|
BIN
docs/pics/2f683fe8-bee8-46a9-86a7-685c8981555856191616.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
docs/pics/7c5e4fbe-8aab-4dd6-a7a0-aae39bfd110f_200.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
docs/pics/862d5e07-ff6e-4c0d-abe4-08488cbf8049_200.png
Normal file
After Width: | Height: | Size: 110 KiB |
BIN
docs/pics/8c001caa-cf3d-4793-a64e-6e7dbc446c0d_200.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
docs/pics/9ccb276e-6840-4150-ae6d-fc57b8eef35b_200.png
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
docs/pics/a79aec4f-aea4-4ee2-87e3-7c7c6049b90c_200.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
docs/pics/d0c1f611-3bc3-446d-8c0b-1b442b0ae8c91_200.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
docs/pics/d546e754-a5b2-4132-be09-b991f163884b_200.png
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
docs/pics/ff98a336-a390-4d1c-adea-0a49e72fad82_200.png
Normal file
After Width: | Height: | Size: 59 KiB |