diff --git a/2014/12/23/my-new-post/index.html b/2014/12/23/my-new-post/index.html index 8d833f7192..c81724f3fd 100644 --- a/2014/12/23/my-new-post/index.html +++ b/2014/12/23/my-new-post/index.html @@ -428,20 +428,20 @@
- 98 + 99 posts
- 125 + 127 categories
- 193 + 197 tags
@@ -466,7 +466,7 @@
- +
diff --git a/2014/12/24/MFC 模态对话框/index.html b/2014/12/24/MFC 模态对话框/index.html index 12d90fe537..fb5fba5a83 100644 --- a/2014/12/24/MFC 模态对话框/index.html +++ b/2014/12/24/MFC 模态对话框/index.html @@ -301,16 +301,16 @@ @@ -451,20 +451,20 @@
- 98 + 99 posts
- 125 + 127 categories
- 193 + 197 tags
@@ -489,7 +489,7 @@
- +
diff --git a/2014/12/30/Clone-Graph-Part-I/index.html b/2014/12/30/Clone-Graph-Part-I/index.html index 5c4a622048..1079b296a6 100644 --- a/2014/12/30/Clone-Graph-Part-I/index.html +++ b/2014/12/30/Clone-Graph-Part-I/index.html @@ -35,8 +35,8 @@ - + @@ -300,20 +300,20 @@
@@ -356,8 +356,8 @@ @@ -470,20 +473,20 @@
- 98 + 99 posts
- 125 + 127 categories
- 193 + 197 tags
@@ -508,7 +511,7 @@
- +
diff --git a/2021/04/18/rust学习笔记/index.html b/2021/04/18/rust学习笔记/index.html new file mode 100644 index 0000000000..0986150773 --- /dev/null +++ b/2021/04/18/rust学习笔记/index.html @@ -0,0 +1,765 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rust学习笔记-所有权一 | Nicksxs's Blog + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+ + + +

Nicksxs's Blog

+ +
+

What hurts more, the pain of hard work or the pain of regret?

+
+ + +
+ + + + + + + + + +
+
+ + +
+ + 0% +
+ + + + +
+
+
+ + +
+ + + + + +
+ + + + + +
+

+ rust学习笔记-所有权一 +

+ + +
+ + + + +
+ + +

最近在看 《rust 权威指南》,还是难度比较大的,它里面的一些概念跟之前的用过的都有比较大的差别
比起有 gc 的虚拟机语言,跟像 C 和 C++这种主动释放内存的,rust 有他的独特点,主要是有三条

+
    +
  • Rust中的每一个值都有一个对应的变量作为它的所有者。
  • +
  • 在同一时间内,值有且只有一个所有者。
  • +
  • 当所有者离开自己的作用域时,它持有的值就会被释放掉。

    这里有两个重点:
  • +
  • s 在进入作用域后才变得有效
  • +
  • 它会保持自己的有效性直到自己离开作用域为止
  • +
+

然后看个案例

+
1
2
let x = 5;
let y = x;
+

这个其实有两种,一般可以认为比较多实现的会使用 copy on write 之类的,先让两个都指向同一个快 5 的存储,在发生变更后开始正式拷贝,但是涉及到内存处理的便利性,对于这类简单类型,可以直接拷贝
但是对于非基础类型

+
1
2
3
4
let s1 = String::from("hello");
let s2 = s1;

println!("{}, world!", s1);
+

有可能认为有两种内存分布可能
先看下 string 的内存结构

第一种可能是

第二种是

我们来尝试编译下

发现有这个错误,其实在 rust 中let y = x这个行为的实质是移动,在赋值给 y 之后 x 就无效了

这样子就不会造成脱离作用域时,对同一块内存区域的二次释放,如果需要复制,可以使用 clone 方法

+
1
2
3
4
let s1 = String::from("hello");
let s2 = s1.clone();

println!("s1 = {}, s2 = {}", s1, s2);
+

这里其实会有点疑惑,为什么前面的x, y 的行为跟 s1, s2 的不一样,其实主要是基本类型和 string 这类的不定大小的类型的内存分配方式不同,x, y这类整型可以直接确定大小,可以直接在栈上分配,而像 string 和其他的变体结构体,其大小都是不能在编译时确定,所以需要在堆上进行分配

+ +
+ + + + + + +
+
请我喝杯咖啡
+ + +
+ + + +
+ +
+ + + + +
+ + + + + + +
+ + +
+
+ +
+
+ + + + +
+ + + + + + + + +
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/404.html b/404.html index 74d085bb2c..2360356e10 100644 --- a/404.html +++ b/404.html @@ -320,20 +320,20 @@
- 98 + 99 posts
- 125 + 127 categories
- 193 + 197 tags
@@ -358,7 +358,7 @@
- +
diff --git a/404/index.html b/404/index.html index 8ba42db3b7..35faf2606e 100644 --- a/404/index.html +++ b/404/index.html @@ -307,20 +307,20 @@
- 98 + 99 posts
- 125 + 127 categories
- 193 + 197 tags
@@ -345,7 +345,7 @@
- +
diff --git a/archives/2014/12/index.html b/archives/2014/12/index.html index 004aa4666b..dc4084150f 100644 --- a/archives/2014/12/index.html +++ b/archives/2014/12/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/archives/2014/index.html b/archives/2014/index.html index 0cf4fdd173..e56e95236c 100644 --- a/archives/2014/index.html +++ b/archives/2014/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/archives/2015/01/index.html b/archives/2015/01/index.html index 92933d17a8..8bac11b701 100644 --- a/archives/2015/01/index.html +++ b/archives/2015/01/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/archives/2015/03/index.html b/archives/2015/03/index.html index 36427feef3..86ea148b41 100644 --- a/archives/2015/03/index.html +++ b/archives/2015/03/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/archives/2015/04/index.html b/archives/2015/04/index.html index dd36dbccc5..3100c1454f 100644 --- a/archives/2015/04/index.html +++ b/archives/2015/04/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/archives/2015/06/index.html b/archives/2015/06/index.html index 60e5123364..1ca98d30f1 100644 --- a/archives/2015/06/index.html +++ b/archives/2015/06/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2015/index.html b/archives/2015/index.html index fe38015163..0f884606f4 100644 --- a/archives/2015/index.html +++ b/archives/2015/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -470,20 +470,20 @@ @@ -508,7 +508,7 @@
- +
diff --git a/archives/2016/07/index.html b/archives/2016/07/index.html index e3adb8f47f..ef6c561061 100644 --- a/archives/2016/07/index.html +++ b/archives/2016/07/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2016/08/index.html b/archives/2016/08/index.html index e6b39de057..04be2a12eb 100644 --- a/archives/2016/08/index.html +++ b/archives/2016/08/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/archives/2016/09/index.html b/archives/2016/09/index.html index b52459914c..f4fbd899a7 100644 --- a/archives/2016/09/index.html +++ b/archives/2016/09/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2016/10/index.html b/archives/2016/10/index.html index caec891660..4886adbd82 100644 --- a/archives/2016/10/index.html +++ b/archives/2016/10/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/archives/2016/11/index.html b/archives/2016/11/index.html index 93587b3e44..b51926583c 100644 --- a/archives/2016/11/index.html +++ b/archives/2016/11/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2016/index.html b/archives/2016/index.html index a075028726..6299eac479 100644 --- a/archives/2016/index.html +++ b/archives/2016/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -430,20 +430,20 @@ @@ -468,7 +468,7 @@
- +
diff --git a/archives/2017/03/index.html b/archives/2017/03/index.html index da4df41484..6fb61b0e0f 100644 --- a/archives/2017/03/index.html +++ b/archives/2017/03/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2017/04/index.html b/archives/2017/04/index.html index f9654030fd..518d2cca78 100644 --- a/archives/2017/04/index.html +++ b/archives/2017/04/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2017/05/index.html b/archives/2017/05/index.html index aab6a3c2be..c393e8ed4a 100644 --- a/archives/2017/05/index.html +++ b/archives/2017/05/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2017/index.html b/archives/2017/index.html index 3e7940a468..803547db4d 100644 --- a/archives/2017/index.html +++ b/archives/2017/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/archives/2019/06/index.html b/archives/2019/06/index.html index 2d1051e2f6..ea8c0642db 100644 --- a/archives/2019/06/index.html +++ b/archives/2019/06/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2019/09/index.html b/archives/2019/09/index.html index fe4b39c56b..2ec69a759f 100644 --- a/archives/2019/09/index.html +++ b/archives/2019/09/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/archives/2019/12/index.html b/archives/2019/12/index.html index 965ef25f92..5ddbcdfc4e 100644 --- a/archives/2019/12/index.html +++ b/archives/2019/12/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2019/index.html b/archives/2019/index.html index a3fe55df0f..8aa707bfb6 100644 --- a/archives/2019/index.html +++ b/archives/2019/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -430,20 +430,20 @@ @@ -468,7 +468,7 @@
- +
diff --git a/archives/2020/01/index.html b/archives/2020/01/index.html index 23092aa537..6640db259c 100644 --- a/archives/2020/01/index.html +++ b/archives/2020/01/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2020/02/index.html b/archives/2020/02/index.html index 2f3def7f84..3907cbf63f 100644 --- a/archives/2020/02/index.html +++ b/archives/2020/02/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/03/index.html b/archives/2020/03/index.html index 2f7304ca94..24662b561f 100644 --- a/archives/2020/03/index.html +++ b/archives/2020/03/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2020/04/index.html b/archives/2020/04/index.html index d98dddbbe7..ecdd36957e 100644 --- a/archives/2020/04/index.html +++ b/archives/2020/04/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/05/index.html b/archives/2020/05/index.html index 9b283e03f4..948b720893 100644 --- a/archives/2020/05/index.html +++ b/archives/2020/05/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2020/06/index.html b/archives/2020/06/index.html index dd806946e7..73a76d6fb6 100644 --- a/archives/2020/06/index.html +++ b/archives/2020/06/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/07/index.html b/archives/2020/07/index.html index 4004155ce6..2ddfb29b6d 100644 --- a/archives/2020/07/index.html +++ b/archives/2020/07/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/08/index.html b/archives/2020/08/index.html index fda4cc2361..fd080b9a11 100644 --- a/archives/2020/08/index.html +++ b/archives/2020/08/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2020/09/index.html b/archives/2020/09/index.html index 1f92681b81..1568ab4ba9 100644 --- a/archives/2020/09/index.html +++ b/archives/2020/09/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/10/index.html b/archives/2020/10/index.html index 3b8b88a5ea..dd570deb45 100644 --- a/archives/2020/10/index.html +++ b/archives/2020/10/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/11/index.html b/archives/2020/11/index.html index bfa8e1f782..7fd3f31220 100644 --- a/archives/2020/11/index.html +++ b/archives/2020/11/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2020/12/index.html b/archives/2020/12/index.html index f378b80d27..a1616d6157 100644 --- a/archives/2020/12/index.html +++ b/archives/2020/12/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2020/index.html b/archives/2020/index.html index ecbcf10be6..d7d4ef4b40 100644 --- a/archives/2020/index.html +++ b/archives/2020/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/2020/page/2/index.html b/archives/2020/page/2/index.html index 6d067bf146..230dd457c7 100644 --- a/archives/2020/page/2/index.html +++ b/archives/2020/page/2/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/2020/page/3/index.html b/archives/2020/page/3/index.html index 9ba6747be9..9a313d9feb 100644 --- a/archives/2020/page/3/index.html +++ b/archives/2020/page/3/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/2020/page/4/index.html b/archives/2020/page/4/index.html index 1c20b37ca9..d7c224f1b7 100644 --- a/archives/2020/page/4/index.html +++ b/archives/2020/page/4/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/2020/page/5/index.html b/archives/2020/page/5/index.html index 97802be643..39e0ce5e76 100644 --- a/archives/2020/page/5/index.html +++ b/archives/2020/page/5/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/2020/page/6/index.html b/archives/2020/page/6/index.html index ac05b9deb8..6c924b06ec 100644 --- a/archives/2020/page/6/index.html +++ b/archives/2020/page/6/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -353,20 +353,20 @@ @@ -391,7 +391,7 @@
- +
diff --git a/archives/2021/01/index.html b/archives/2021/01/index.html index 7a972e977f..7148238db4 100644 --- a/archives/2021/01/index.html +++ b/archives/2021/01/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2021/02/index.html b/archives/2021/02/index.html index 0ff9fa5f27..731d75bee5 100644 --- a/archives/2021/02/index.html +++ b/archives/2021/02/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/archives/2021/03/index.html b/archives/2021/03/index.html index 667a21d795..8f59f2fff1 100644 --- a/archives/2021/03/index.html +++ b/archives/2021/03/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -390,20 +390,20 @@ @@ -428,7 +428,7 @@
- +
diff --git a/archives/2021/04/index.html b/archives/2021/04/index.html index e3a9f55d47..f17cb724fe 100644 --- a/archives/2021/04/index.html +++ b/archives/2021/04/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2021
+ +
@@ -330,20 +350,20 @@ @@ -368,7 +388,7 @@
- +
diff --git a/archives/2021/index.html b/archives/2021/index.html index b80ed5e493..a9b5e16cdd 100644 --- a/archives/2021/index.html +++ b/archives/2021/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2021
+ +
@@ -396,26 +416,6 @@
- -
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/2021/page/2/index.html b/archives/2021/page/2/index.html index 329af2db1b..56915922d4 100644 --- a/archives/2021/page/2/index.html +++ b/archives/2021/page/2/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2021
+ +
@@ -413,20 +433,20 @@ @@ -451,7 +471,7 @@
- +
diff --git a/archives/index.html b/archives/index.html index df8914320d..644eaaacb5 100644 --- a/archives/index.html +++ b/archives/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2021
+ +
@@ -396,26 +416,6 @@
- -
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/page/10/index.html b/archives/page/10/index.html index 82f106376a..61d25f9e9c 100644 --- a/archives/page/10/index.html +++ b/archives/page/10/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2015
+ +
@@ -456,20 +476,20 @@ @@ -494,7 +514,7 @@
- +
diff --git a/archives/page/2/index.html b/archives/page/2/index.html index c73eaef416..beb144d890 100644 --- a/archives/page/2/index.html +++ b/archives/page/2/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2021
+ +
@@ -399,26 +419,6 @@
- -
@@ -496,20 +496,20 @@ @@ -534,7 +534,7 @@
- +
diff --git a/archives/page/3/index.html b/archives/page/3/index.html index 6d8d1df8a6..d8ac213cc5 100644 --- a/archives/page/3/index.html +++ b/archives/page/3/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2020
+ +
@@ -396,26 +416,6 @@
- -
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/page/4/index.html b/archives/page/4/index.html index 7ff982eb8f..c43f8ab9ea 100644 --- a/archives/page/4/index.html +++ b/archives/page/4/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2020
+ +
@@ -396,26 +416,6 @@
- -
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/page/5/index.html b/archives/page/5/index.html index c97d113e4a..828d612750 100644 --- a/archives/page/5/index.html +++ b/archives/page/5/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2020
+ +
@@ -396,26 +416,6 @@
- -
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/page/6/index.html b/archives/page/6/index.html index ea4ff0a411..2509d35bf5 100644 --- a/archives/page/6/index.html +++ b/archives/page/6/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2020
+ +
@@ -396,26 +416,6 @@
- -
@@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/archives/page/7/index.html b/archives/page/7/index.html index 157af07c48..1391a14500 100644 --- a/archives/page/7/index.html +++ b/archives/page/7/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2020
+ +
@@ -395,29 +415,6 @@
-
- 2019 -
- -
@@ -496,20 +493,20 @@ @@ -534,7 +531,7 @@
- +
diff --git a/archives/page/8/index.html b/archives/page/8/index.html index 046afc5915..b4f6df2339 100644 --- a/archives/page/8/index.html +++ b/archives/page/8/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2019
+ +
@@ -398,29 +418,6 @@
-
- 2016 -
- -
@@ -499,20 +496,20 @@ @@ -537,7 +534,7 @@
- +
diff --git a/archives/page/9/index.html b/archives/page/9/index.html index 9fa556a150..049b70f0e4 100644 --- a/archives/page/9/index.html +++ b/archives/page/9/index.html @@ -208,7 +208,7 @@
- Good! 98 posts in total. Keep on posting. + Good! 99 posts in total. Keep on posting.
@@ -216,6 +216,26 @@ 2016
+ +
@@ -399,26 +419,6 @@
- -
@@ -496,20 +496,20 @@ @@ -534,7 +534,7 @@
- +
diff --git a/atom.xml b/atom.xml index a66536256c..4d7a2da02c 100644 --- a/atom.xml +++ b/atom.xml @@ -6,7 +6,7 @@ - 2021-04-11T15:38:07.755Z + 2021-04-18T14:06:53.609Z https://nicksxs.me/ @@ -16,6 +16,41 @@ Hexo + + rust学习笔记-所有权一 + + https://nicksxs.me/2021/04/18/rust%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/ + 2021-04-18T14:04:01.000Z + 2021-04-18T14:06:53.609Z + + + + + + + + <p>最近在看 《rust 权威指南》,还是难度比较大的,它里面的一些概念跟之前的用过的都有比较大的差别<br>比起有 gc 的虚拟机语言,跟像 C 和 C++这种主动释放内存的,rust + + + + + + + + + + + + + + + + + + + + + 聊聊厦门旅游的好与不好 @@ -273,10 +308,10 @@ - - + + @@ -832,51 +867,4 @@ - - Leetcode 155 最小栈(Min Stack) 题解分析 - - https://nicksxs.me/2020/12/06/Leetcode-155-%E6%9C%80%E5%B0%8F%E6%A0%88-Min-Stack-%E9%A2%98%E8%A7%A3%E5%88%86%E6%9E%90/ - 2020-12-06T13:55:55.000Z - 2020-12-06T13:55:55.404Z - - - - - - - - <h2 id="题目介绍"><a href="#题目介绍" class="headerlink" title="题目介绍"></a>题目介绍</h2><p>Design a stack that supports push, pop, top, and retrieving - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/baidu_verify_Gl8jtoDV4z.html b/baidu_verify_Gl8jtoDV4z.html index a760742d58..990288afc3 100644 --- a/baidu_verify_Gl8jtoDV4z.html +++ b/baidu_verify_Gl8jtoDV4z.html @@ -309,20 +309,20 @@ @@ -347,7 +347,7 @@
- +
diff --git a/baidusitemap.xml b/baidusitemap.xml index cea77166d9..cc6c4d8d0f 100644 --- a/baidusitemap.xml +++ b/baidusitemap.xml @@ -1,6 +1,9 @@ + https://nicksxs.me/2021/04/18/rust%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/ + 2021-04-18 + https://nicksxs.me/2021/04/11/%E8%81%8A%E8%81%8A%E5%8E%A6%E9%97%A8%E6%97%85%E6%B8%B8%E7%9A%84%E5%A5%BD%E4%B8%8E%E4%B8%8D%E5%A5%BD/ 2021-04-11 @@ -222,9 +225,6 @@ https://nicksxs.me/2019/12/10/Redis-Part-1/ 2020-01-12 - - https://nicksxs.me/2019/06/18/openresty/ - 2020-01-12 https://nicksxs.me/2015/03/11/Reverse-Bits/ 2020-01-12 @@ -232,28 +232,31 @@ https://nicksxs.me/2016/11/10/php-abstract-class-and-interface/ 2020-01-12 - https://nicksxs.me/2015/03/13/Reverse-Integer/ + https://nicksxs.me/2016/09/29/binary-watch/ + 2020-01-12 + + https://nicksxs.me/2019/06/18/openresty/ 2020-01-12 https://nicksxs.me/2017/05/09/ambari-summary/ 2020-01-12 - https://nicksxs.me/2016/09/29/binary-watch/ + https://nicksxs.me/2016/08/14/docker-mysql-cluster/ 2020-01-12 https://nicksxs.me/2016/10/11/minimum-size-subarray-sum-209/ 2020-01-12 - https://nicksxs.me/2015/01/14/Two-Sum/ + https://nicksxs.me/2015/03/13/Reverse-Integer/ 2020-01-12 - https://nicksxs.me/2016/08/14/docker-mysql-cluster/ + https://nicksxs.me/2015/01/14/Two-Sum/ 2020-01-12 - https://nicksxs.me/2015/01/04/Path-Sum/ + https://nicksxs.me/2015/06/22/invert-binary-tree/ 2020-01-12 - https://nicksxs.me/2015/06/22/invert-binary-tree/ + https://nicksxs.me/2016/07/13/swoole-websocket-test/ 2020-01-12 https://nicksxs.me/2014/12/23/my-new-post/ @@ -262,17 +265,14 @@ https://nicksxs.me/2015/01/16/pcre-intro-and-a-simple-package/ 2020-01-12 - https://nicksxs.me/2017/04/25/rabbitmq-tips/ + https://nicksxs.me/2015/01/04/Path-Sum/ 2020-01-12 - https://nicksxs.me/2016/07/13/swoole-websocket-test/ + https://nicksxs.me/2017/04/25/rabbitmq-tips/ 2020-01-12 https://nicksxs.me/2015/03/11/Number-Of-1-Bits/ 2020-01-12 - - https://nicksxs.me/2016/10/12/summary-ranges-228/ - 2020-01-12 https://nicksxs.me/2017/03/28/spark-little-tips/ 2020-01-12 @@ -282,6 +282,9 @@ https://nicksxs.me/2014/12/30/Clone-Graph-Part-I/ 2020-01-12 + + https://nicksxs.me/2016/10/12/summary-ranges-228/ + 2020-01-12 https://nicksxs.me/2019/09/23/AbstractQueuedSynchronizer/ 2020-01-12 diff --git a/categories/Binary-Tree/index.html b/categories/Binary-Tree/index.html index 2be3accff8..4dfd4ce542 100644 --- a/categories/Binary-Tree/index.html +++ b/categories/Binary-Tree/index.html @@ -353,20 +353,20 @@ @@ -391,7 +391,7 @@
- +
diff --git a/categories/C/Mysql/index.html b/categories/C/Mysql/index.html index d5fe451ef0..6835354d1c 100644 --- a/categories/C/Mysql/index.html +++ b/categories/C/Mysql/index.html @@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/categories/C/Redis/index.html b/categories/C/Redis/index.html index d20fb74d3c..93ba1dae95 100644 --- a/categories/C/Redis/index.html +++ b/categories/C/Redis/index.html @@ -473,20 +473,20 @@ @@ -511,7 +511,7 @@
- +
diff --git a/categories/C/index.html b/categories/C/index.html index 2e94e597ce..dfc484437d 100644 --- a/categories/C/index.html +++ b/categories/C/index.html @@ -493,20 +493,20 @@ @@ -531,7 +531,7 @@
- +
diff --git a/categories/C/page/2/index.html b/categories/C/page/2/index.html index 9d1904775d..7f7ab2f6f5 100644 --- a/categories/C/page/2/index.html +++ b/categories/C/page/2/index.html @@ -356,20 +356,20 @@ @@ -394,7 +394,7 @@
- +
diff --git a/categories/DP/index.html b/categories/DP/index.html index c020c8e4ec..12d8c2c39c 100644 --- a/categories/DP/index.html +++ b/categories/DP/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Dubbo-RPC-SPI/index.html b/categories/Dubbo-RPC-SPI/index.html index 14a79359e0..de97a0fd10 100644 --- a/categories/Dubbo-RPC-SPI/index.html +++ b/categories/Dubbo-RPC-SPI/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/Dubbo-RPC/index.html b/categories/Dubbo-RPC/index.html index 507be164a5..1b21b89627 100644 --- a/categories/Dubbo-RPC/index.html +++ b/categories/Dubbo-RPC/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Dubbo-线程池/index.html b/categories/Dubbo-线程池/index.html index 423e5aa47c..6cfcfe58ac 100644 --- a/categories/Dubbo-线程池/index.html +++ b/categories/Dubbo-线程池/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Dubbo/SPI/Adaptive/index.html b/categories/Dubbo/SPI/Adaptive/index.html index 5ee36e228a..697e1c638a 100644 --- a/categories/Dubbo/SPI/Adaptive/index.html +++ b/categories/Dubbo/SPI/Adaptive/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Dubbo/SPI/index.html b/categories/Dubbo/SPI/index.html index 39eb48b445..38d98efd2a 100644 --- a/categories/Dubbo/SPI/index.html +++ b/categories/Dubbo/SPI/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/Dubbo/index.html b/categories/Dubbo/index.html index dc984cf6a4..8a90c1f70f 100644 --- a/categories/Dubbo/index.html +++ b/categories/Dubbo/index.html @@ -373,20 +373,20 @@ @@ -411,7 +411,7 @@
- +
diff --git a/categories/Dubbo/容错机制/index.html b/categories/Dubbo/容错机制/index.html index 92f3c4384a..de21c56513 100644 --- a/categories/Dubbo/容错机制/index.html +++ b/categories/Dubbo/容错机制/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Dubbo/线程池/ThreadPool/index.html b/categories/Dubbo/线程池/ThreadPool/index.html index afef9b26d4..321743fbd3 100644 --- a/categories/Dubbo/线程池/ThreadPool/index.html +++ b/categories/Dubbo/线程池/ThreadPool/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Dubbo/线程池/index.html b/categories/Dubbo/线程池/index.html index 14dea8c168..03fbbcaef3 100644 --- a/categories/Dubbo/线程池/index.html +++ b/categories/Dubbo/线程池/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Filter/index.html b/categories/Filter/index.html index c282c27d00..be34ef4324 100644 --- a/categories/Filter/index.html +++ b/categories/Filter/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Interceptor-AOP/index.html b/categories/Interceptor-AOP/index.html index b5af97c232..c884776207 100644 --- a/categories/Interceptor-AOP/index.html +++ b/categories/Interceptor-AOP/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/Apollo/index.html b/categories/Java/Apollo/index.html index 1acd3ba6d2..6206a07201 100644 --- a/categories/Java/Apollo/index.html +++ b/categories/Java/Apollo/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/Apollo/value/index.html b/categories/Java/Apollo/value/index.html index 394355107d..d716a78970 100644 --- a/categories/Java/Apollo/value/index.html +++ b/categories/Java/Apollo/value/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/Design-Patterns/index.html b/categories/Java/Design-Patterns/index.html index 1a4c377e05..ea6425120c 100644 --- a/categories/Java/Design-Patterns/index.html +++ b/categories/Java/Design-Patterns/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/GC/index.html b/categories/Java/GC/index.html index 8829cd8d46..5a926dafe4 100644 --- a/categories/Java/GC/index.html +++ b/categories/Java/GC/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/GC/jvm/index.html b/categories/Java/GC/jvm/index.html index 7c50106e0f..0a4f017754 100644 --- a/categories/Java/GC/jvm/index.html +++ b/categories/Java/GC/jvm/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/JVM/index.html b/categories/Java/JVM/index.html index 9e1b17f957..8e2b041830 100644 --- a/categories/Java/JVM/index.html +++ b/categories/Java/JVM/index.html @@ -333,20 +333,20 @@ @@ -371,7 +371,7 @@
- +
diff --git a/categories/Java/Maven/index.html b/categories/Java/Maven/index.html index 11b3b32ec5..4c02551eea 100644 --- a/categories/Java/Maven/index.html +++ b/categories/Java/Maven/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/Mybatis/index.html b/categories/Java/Mybatis/index.html index 2476c1529e..38c0cdf6ae 100644 --- a/categories/Java/Mybatis/index.html +++ b/categories/Java/Mybatis/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/Java/Singleton/index.html b/categories/Java/Singleton/index.html index dbbbd2d4fa..0d573d93ce 100644 --- a/categories/Java/Singleton/index.html +++ b/categories/Java/Singleton/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Java/index.html b/categories/Java/index.html index b0ba9f4d03..2ebb011a30 100644 --- a/categories/Java/index.html +++ b/categories/Java/index.html @@ -29,7 +29,7 @@ - + @@ -40,7 +40,7 @@ - + - Category: Java | Nicksxs's Blog + Category: java | Nicksxs's Blog + + + + + + +nzi-count"> + + + + +
+ + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Category: Rust | Nicksxs's Blog + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+ + + +

Nicksxs's Blog

+ +
+

What hurts more, the pain of hard work or the pain of regret?

+
+ + +
+ + + + + + + + + +
+
+ + +
+ + 0% +
+ + + + +
+
+
+ + +
+ + + + + +
+
+
+

Rust + Category +

+
+ + +
+ 2021 +
+ + + +
+
+ + + + + + + + +
+ + + + +
+ + + + + + + + +
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/categories/Spring/Mybatis/index.html b/categories/Spring/Mybatis/index.html index ec0e979026..7a69a0aaa6 100644 --- a/categories/Spring/Mybatis/index.html +++ b/categories/Spring/Mybatis/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/Spring/Servlet/Interceptor/AOP/index.html b/categories/Spring/Servlet/Interceptor/AOP/index.html index e02014683e..1e0cf75507 100644 --- a/categories/Spring/Servlet/Interceptor/AOP/index.html +++ b/categories/Spring/Servlet/Interceptor/AOP/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Spring/Servlet/Interceptor/index.html b/categories/Spring/Servlet/Interceptor/index.html index 97137affa9..ba973dd32d 100644 --- a/categories/Spring/Servlet/Interceptor/index.html +++ b/categories/Spring/Servlet/Interceptor/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Spring/Servlet/index.html b/categories/Spring/Servlet/index.html index 346eed60e9..cbd7c16cb5 100644 --- a/categories/Spring/Servlet/index.html +++ b/categories/Spring/Servlet/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/Spring/index.html b/categories/Spring/index.html index 2cd059080b..b00f7817b2 100644 --- a/categories/Spring/index.html +++ b/categories/Spring/index.html @@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/categories/Thread-dump/index.html b/categories/Thread-dump/index.html index 451de5865c..103fffdaf8 100644 --- a/categories/Thread-dump/index.html +++ b/categories/Thread-dump/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/data-analysis/index.html b/categories/data-analysis/index.html index 276e9ea9aa..954022637f 100644 --- a/categories/data-analysis/index.html +++ b/categories/data-analysis/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/docker/index.html b/categories/docker/index.html index 042db6235c..d652010957 100644 --- a/categories/docker/index.html +++ b/categories/docker/index.html @@ -370,20 +370,20 @@ @@ -408,7 +408,7 @@
- +
diff --git a/categories/docker/介绍/index.html b/categories/docker/介绍/index.html index 3e69380a7e..b6bfd16210 100644 --- a/categories/docker/介绍/index.html +++ b/categories/docker/介绍/index.html @@ -350,20 +350,20 @@ @@ -388,7 +388,7 @@
- +
diff --git a/categories/docker/发行版本/index.html b/categories/docker/发行版本/index.html index 97b985a466..c2f90151d4 100644 --- a/categories/docker/发行版本/index.html +++ b/categories/docker/发行版本/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/index.html b/categories/index.html index a1b0cfc87b..69418a73f8 100644 --- a/categories/index.html +++ b/categories/index.html @@ -228,10 +228,10 @@
- 125 categories in total + 127 categories in total
- +
@@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/leetcode/index.html b/categories/leetcode/index.html index 6c327125b9..e38e143728 100644 --- a/categories/leetcode/index.html +++ b/categories/leetcode/index.html @@ -499,20 +499,20 @@ @@ -537,7 +537,7 @@
- +
diff --git a/categories/leetcode/java/Binary-Tree/DFS/index.html b/categories/leetcode/java/Binary-Tree/DFS/index.html index d440021819..2f9989bccb 100644 --- a/categories/leetcode/java/Binary-Tree/DFS/index.html +++ b/categories/leetcode/java/Binary-Tree/DFS/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/categories/leetcode/java/Binary-Tree/index.html b/categories/leetcode/java/Binary-Tree/index.html index adf8deac23..7a2824788c 100644 --- a/categories/leetcode/java/Binary-Tree/index.html +++ b/categories/leetcode/java/Binary-Tree/index.html @@ -353,20 +353,20 @@ @@ -391,7 +391,7 @@
- +
diff --git a/categories/leetcode/java/DP/index.html b/categories/leetcode/java/DP/index.html index 1f3c8495b1..b5a1a767eb 100644 --- a/categories/leetcode/java/DP/index.html +++ b/categories/leetcode/java/DP/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/leetcode/java/index.html b/categories/leetcode/java/index.html index f3feb16ed3..e38a46ed7f 100644 --- a/categories/leetcode/java/index.html +++ b/categories/leetcode/java/index.html @@ -473,20 +473,20 @@ @@ -511,7 +511,7 @@
- +
diff --git a/categories/leetcode/java/linked-list/index.html b/categories/leetcode/java/linked-list/index.html index 5b1eaa206c..fcb7c14689 100644 --- a/categories/leetcode/java/linked-list/index.html +++ b/categories/leetcode/java/linked-list/index.html @@ -29,7 +29,7 @@ - + @@ -40,7 +40,7 @@ - + - Category: linked list | Nicksxs's Blog + Category: Linked List | Nicksxs's Blog - - - - - - -codeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})(); - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Category: 语言 | Nicksxs's Blog + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+ + + +

Nicksxs's Blog

+ +
+

What hurts more, the pain of hard work or the pain of regret?

+
+ + +
+ + + + + + + + + +
+
+ + +
+ + 0% +
+ + + + +
+
+
+ + +
+ + + + + +
+
+
+

语言 + Category +

+
+ + +
+ 2021 +
+ + + +
+
+ + + + + + + + +
+ + + + +
+ + + + + + + + +
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/categories/读后感/index.html b/categories/读后感/index.html index b6e046bb19..ebd531e7c3 100644 --- a/categories/读后感/index.html +++ b/categories/读后感/index.html @@ -333,20 +333,20 @@ @@ -371,7 +371,7 @@
- +
diff --git a/categories/读后感/村上春树/index.html b/categories/读后感/村上春树/index.html index 2b00ce6f52..6abf315cb9 100644 --- a/categories/读后感/村上春树/index.html +++ b/categories/读后感/村上春树/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/读后感/白岩松/index.html b/categories/读后感/白岩松/index.html index b48e04c3ef..58e174192e 100644 --- a/categories/读后感/白岩松/index.html +++ b/categories/读后感/白岩松/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/读后感/白岩松/幸福了吗/index.html b/categories/读后感/白岩松/幸福了吗/index.html index 29535bc738..59954dfe97 100644 --- a/categories/读后感/白岩松/幸福了吗/index.html +++ b/categories/读后感/白岩松/幸福了吗/index.html @@ -310,20 +310,20 @@ @@ -348,7 +348,7 @@
- +
diff --git a/categories/问题排查/index.html b/categories/问题排查/index.html index 41a4a3e38e..8951191280 100644 --- a/categories/问题排查/index.html +++ b/categories/问题排查/index.html @@ -330,20 +330,20 @@ @@ -368,7 +368,7 @@
- +
diff --git a/css/main.css b/css/main.css index 6592ba5d17..b0fd22c876 100644 --- a/css/main.css +++ b/css/main.css @@ -1261,7 +1261,7 @@ pre .javascript .function { } .links-of-author a::before, .links-of-author span.exturl::before { - background: #ec7cf1; + background: #f0ffcd; border-radius: 50%; content: ' '; display: inline-block; diff --git a/index.html b/index.html index bdee9ce02f..4a88f7964f 100644 --- a/index.html +++ b/index.html @@ -203,6 +203,115 @@ +
+ + + + + +
+

+ + +

+ + +
+ + + + +
+ + +

最近在看 《rust 权威指南》,还是难度比较大的,它里面的一些概念跟之前的用过的都有比较大的差别
比起有 gc 的虚拟机语言,跟像 C 和 C++这种主动释放内存的,rust 有他的独特点,主要是有三条

+
    +
  • Rust中的每一个值都有一个对应的变量作为它的所有者。
  • +
  • 在同一时间内,值有且只有一个所有者。
  • +
  • 当所有者离开自己的作用域时,它持有的值就会被释放掉。

    这里有两个重点:
  • +
  • s 在进入作用域后才变得有效
  • +
  • 它会保持自己的有效性直到自己离开作用域为止
  • +
+

然后看个案例

+
1
2
let x = 5;
let y = x;
+

这个其实有两种,一般可以认为比较多实现的会使用 copy on write 之类的,先让两个都指向同一个快 5 的存储,在发生变更后开始正式拷贝,但是涉及到内存处理的便利性,对于这类简单类型,可以直接拷贝
但是对于非基础类型

+
1
2
3
4
let s1 = String::from("hello");
let s2 = s1;

println!("{}, world!", s1);
+

有可能认为有两种内存分布可能
先看下 string 的内存结构

第一种可能是

第二种是

我们来尝试编译下

发现有这个错误,其实在 rust 中let y = x这个行为的实质是移动,在赋值给 y 之后 x 就无效了

这样子就不会造成脱离作用域时,对同一块内存区域的二次释放,如果需要复制,可以使用 clone 方法

+
1
2
3
4
let s1 = String::from("hello");
let s2 = s1.clone();

println!("s1 = {}, s2 = {}", s1, s2);
+

这里其实会有点疑惑,为什么前面的x, y 的行为跟 s1, s2 的不一样,其实主要是基本类型和 string 这类的不定大小的类型的内存分配方式不同,x, y这类整型可以直接确定大小,可以直接在栈上分配,而像 string 和其他的变体结构体,其大小都是不能在编译时确定,所以需要在堆上进行分配

+ + +
+ + + + + + +
+
+
+
+ + + + + + +
@@ -648,100 +757,6 @@ - - - -
- - - - - -
-

- - -

- - -
- - - - -
- - -

事情源于周末来回家发生的两件事情,先是回去的时候从高铁下车要坐公交,现在算是有个比较好的临时候车点了,但是可能由于疫情好转,晚上都不用检查健康码就可以进候车点,但是上公交的时候还是需要看健康码,一般情况下从高铁下来的,各个地方的人都有,而且也不太清楚这边上公交车需要查验健康码,我的一个看法是候车的时候就应该放个横幅告示,或者再配合喇叭循环播放,请提前准备好健康码,上车前需要查验,因为像这周的情况,我乘坐的那辆车是间隔时间比较长,而且终点是工业开发区,可能是比较多外来务工人员的目的地,正好这部分人可能对于操作手机检验健康码这个事情不太熟悉,所以结果就是头上几个不知道怎么搞出来健康码,然后让几乎有满满一整车的人在后面堵着,司机又非常厌烦那些没有提前出示健康码的,有位乘客搞得久了点,还被误以为没刷卡买票,差点吵起来,其实公共交通或者高铁站负责的在公交指引路线上多写一句上车前需要查验健康码,可能就能改善比较多,还有就是那个积水的路,这个吐槽起来就一大坨了,整个绍兴像 dayuejin 一样到处都是破路。
第二个就是来杭州的时候,经过人行横道,远处车道的公交车停下来等我们了,为了少添麻烦总想快点穿过去,但是这时靠近我们的车道(晚上光线较暗,可见度不佳)有一辆从远处来的奥迪 A4 还是 A5 这种的车反而想加速冲过去,如果少看一下可能我已经残了,交规考的靠近人行道要减速好像基本都是个摆设了,杭州也只有公交车因为一些考核指标原因会主动礼让,人其实需要有同理心,虽然可能有些人是开车多于骑车走路的,但是总也不可能永远不穿人行道吧,甚至这些人可能还会在人行道红灯的时候走过去。这个事情不是吐槽公共交通的,只是也有些许关系,想起来还有一件事也是刚才来杭州的时候看到的,等公交的时候看到有辆路虎要加塞,而目标车道刚好是辆大货车,大货车看到按了喇叭,路虎犹豫了下还是挤进去了,可能是对路虎的扛撞性能非常自信吧,反正我是挺后怕的,这种级别的车,被撞了的话估计还是鸡蛋撞石头,吨位惯性在那,这里再延伸下,挺多开豪车的人好像都觉得这路上路权更大一些,谁谁都得让着他,可能实际吃亏的不多,所以越加巩固了这种思维,当真的碰到不管的可能就会明白了,路权这个事情在天朝也基本没啥人重视,也没想说个结论,就到这吧

- - -
- - - - - - -
-
-
-
- - - - @@ -851,7 +866,7 @@
- +
diff --git a/leancloud.memo b/leancloud.memo index b620101960..3ba2c6f2ad 100644 --- a/leancloud.memo +++ b/leancloud.memo @@ -99,4 +99,5 @@ {"title":"聊聊 Linux 下的 top 命令","url":"/2021/03/28/聊聊-Linux-下的-top-命令/"}, {"title":"2020 年终总结","url":"/2021/03/31/2020-年终总结/"}, {"title":"聊聊 dubbo 的线程池","url":"/2021/04/04/聊聊-dubbo-的线程池/"}, +{"title":"聊聊厦门旅游的好与不好","url":"/2021/04/11/聊聊厦门旅游的好与不好/"}, ] \ No newline at end of file diff --git a/leancloud_counter_security_urls.json b/leancloud_counter_security_urls.json index b595523f4c..63f4fedd90 100644 --- a/leancloud_counter_security_urls.json +++ b/leancloud_counter_security_urls.json @@ -1 +1 @@ -[{"title":"村上春树《1Q84》读后感","url":"/2019/12/18/1Q84读后感/"},{"title":"2019年终总结","url":"/2020/02/01/2019年终总结/"},{"title":"34_Search_for_a_Range","url":"/2016/08/14/34-Search-for-a-Range/"},{"title":"2020年中总结","url":"/2020/07/11/2020年中总结/"},{"title":"add-two-number","url":"/2015/04/14/Add-Two-Number/"},{"title":"AbstractQueuedSynchronizer","url":"/2019/09/23/AbstractQueuedSynchronizer/"},{"title":"Clone Graph Part I","url":"/2014/12/30/Clone-Graph-Part-I/"},{"title":"Apollo 的 value 注解是怎么自动更新的","url":"/2020/11/01/Apollo-的-value-注解是怎么自动更新的/"},{"title":"Comparator使用小记","url":"/2020/04/05/Comparator使用小记/"},{"title":"2020 年终总结","url":"/2021/03/31/2020-年终总结/"},{"title":"G1收集器概述","url":"/2020/02/09/G1收集器概述/"},{"title":"Leetcode 105 从前序与中序遍历序列构造二叉树(Construct Binary Tree from Preorder and Inorder Traversal) 题解分析","url":"/2020/12/13/Leetcode-105-从前序与中序遍历序列构造二叉树-Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal-题解分析/"},{"title":"Leetcode 104 二叉树的最大深度(Maximum Depth of Binary Tree) 题解分析","url":"/2020/10/25/Leetcode-104-二叉树的最大深度-Maximum-Depth-of-Binary-Tree-题解分析/"},{"title":"Leetcode 124 二叉树中的最大路径和(Binary Tree Maximum Path Sum) 题解分析","url":"/2021/01/24/Leetcode-124-二叉树中的最大路径和-Binary-Tree-Maximum-Path-Sum-题解分析/"},{"title":"Leetcode 2 Add Two Numbers 题解分析","url":"/2020/10/11/Leetcode-2-Add-Two-Numbers-题解分析/"},{"title":"Leetcode 160 相交链表(intersection-of-two-linked-lists) 题解分析","url":"/2021/01/10/Leetcode-160-相交链表-intersection-of-two-linked-lists-题解分析/"},{"title":"Leetcode 121 买卖股票的最佳时机(Best Time to Buy and Sell Stock) 题解分析","url":"/2021/03/14/Leetcode-121-买卖股票的最佳时机-Best-Time-to-Buy-and-Sell-Stock-题解分析/"},{"title":"Leetcode 3 Longest Substring Without Repeating Characters 题解分析","url":"/2020/09/20/Leetcode-3-Longest-Substring-Without-Repeating-Characters-题解分析/"},{"title":"Leetcode 155 最小栈(Min Stack) 题解分析","url":"/2020/12/06/Leetcode-155-最小栈-Min-Stack-题解分析/"},{"title":"leetcode no.3","url":"/2015/04/15/Leetcode-No-3/"},{"title":"Linux 下 grep 命令的一点小技巧","url":"/2020/08/06/Linux-下-grep-命令的一点小技巧/"},{"title":"Leetcode 234 回文链表(Palindrome Linked List) 题解分析","url":"/2020/11/15/Leetcode-234-回文联表-Palindrome-Linked-List-题解分析/"},{"title":"MFC 模态对话框","url":"/2014/12/24/MFC 模态对话框/"},{"title":"Path Sum","url":"/2015/01/04/Path-Sum/"},{"title":"Maven实用小技巧","url":"/2020/02/16/Maven实用小技巧/"},{"title":"Number of 1 Bits","url":"/2015/03/11/Number-Of-1-Bits/"},{"title":"Redis_分布式锁","url":"/2019/12/10/Redis-Part-1/"},{"title":"Reverse Bits","url":"/2015/03/11/Reverse-Bits/"},{"title":"Reverse Integer","url":"/2015/03/13/Reverse-Integer/"},{"title":"ambari-summary","url":"/2017/05/09/ambari-summary/"},{"title":"binary-watch","url":"/2016/09/29/binary-watch/"},{"title":"two sum","url":"/2015/01/14/Two-Sum/"},{"title":"docker-mysql-cluster","url":"/2016/08/14/docker-mysql-cluster/"},{"title":"docker比一般多一点的初学者介绍","url":"/2020/03/08/docker比一般多一点的初学者介绍/"},{"title":"docker比一般多一点的初学者介绍三","url":"/2020/03/21/docker比一般多一点的初学者介绍三/"},{"title":"docker比一般多一点的初学者介绍二","url":"/2020/03/15/docker比一般多一点的初学者介绍二/"},{"title":"docker使用中发现的echo命令的一个小技巧及其他","url":"/2020/03/29/echo命令的一个小技巧/"},{"title":"invert-binary-tree","url":"/2015/06/22/invert-binary-tree/"},{"title":"minimum-size-subarray-sum-209","url":"/2016/10/11/minimum-size-subarray-sum-209/"},{"title":"gogs使用webhook部署react单页应用","url":"/2020/02/22/gogs使用webhook部署react单页应用/"},{"title":"C++ 指针使用中的一个小问题","url":"/2014/12/23/my-new-post/"},{"title":"mybatis 的 $ 和 # 是有啥区别","url":"/2020/09/06/mybatis-的-和-是有啥区别/"},{"title":"pcre-intro-and-a-simple-package","url":"/2015/01/16/pcre-intro-and-a-simple-package/"},{"title":"php-abstract-class-and-interface","url":"/2016/11/10/php-abstract-class-and-interface/"},{"title":"rabbitmq-tips","url":"/2017/04/25/rabbitmq-tips/"},{"title":"openresty","url":"/2019/06/18/openresty/"},{"title":"redis数据结构介绍三-第三部分 整数集合","url":"/2020/01/10/redis数据结构介绍三/"},{"title":"redis数据结构介绍二-第二部分 跳表","url":"/2020/01/04/redis数据结构介绍二/"},{"title":"redis数据结构介绍五-第五部分 对象","url":"/2020/01/20/redis数据结构介绍五/"},{"title":"redis数据结构介绍四-第四部分 压缩表","url":"/2020/01/19/redis数据结构介绍四/"},{"title":"spark-little-tips","url":"/2017/03/28/spark-little-tips/"},{"title":"summary-ranges-228","url":"/2016/10/12/summary-ranges-228/"},{"title":"swoole-websocket-test","url":"/2016/07/13/swoole-websocket-test/"},{"title":"《垃圾回收算法手册读书》笔记之整理算法","url":"/2021/03/07/《垃圾回收算法手册读书》笔记之整理算法/"},{"title":"关于公共交通再吐个槽","url":"/2021/03/21/关于公共交通再吐个槽/"},{"title":"周末我在老丈人家打了天小工","url":"/2020/08/16/周末我在老丈人家打了天小工/"},{"title":"在老丈人家的小工记三","url":"/2020/09/13/在老丈人家的小工记三/"},{"title":"从丁仲礼被美国制裁聊点啥","url":"/2020/12/20/从丁仲礼被美国制裁聊点啥/"},{"title":"在老丈人家的小工记五","url":"/2020/10/18/在老丈人家的小工记五/"},{"title":"从清华美院学姐聊聊我们身边的恶人","url":"/2020/11/29/从清华美院学姐聊聊我们身边的恶人/"},{"title":"在老丈人家的小工记四","url":"/2020/09/26/在老丈人家的小工记四/"},{"title":"寄生虫观后感","url":"/2020/03/01/寄生虫观后感/"},{"title":"我是如何走上跑步这条不归路的","url":"/2020/07/26/我是如何走上跑步这条不归路的/"},{"title":"聊聊 Dubbo 的 SPI 续之自适应拓展","url":"/2020/06/06/聊聊-Dubbo-的-SPI-续之自适应拓展/"},{"title":"聊聊 Dubbo 的 SPI","url":"/2020/05/31/聊聊-Dubbo-的-SPI/"},{"title":"关于读书打卡与分享","url":"/2021/02/07/关于读书打卡与分享/"},{"title":"聊聊 Java 的类加载机制一","url":"/2020/11/08/聊聊-Java-的类加载机制/"},{"title":"聊聊 Java 的 equals 和 hashCode 方法","url":"/2021/01/03/聊聊-Java-的-equals-和-hashCode-方法/"},{"title":"聊聊 dubbo 的线程池","url":"/2021/04/04/聊聊-dubbo-的线程池/"},{"title":"聊聊 mysql 的 MVCC 续篇","url":"/2020/05/02/聊聊-mysql-的-MVCC-续篇/"},{"title":"聊聊 mysql 的 MVCC 续续篇之锁分析","url":"/2020/05/10/聊聊-mysql-的-MVCC-续续篇之加锁分析/"},{"title":"聊聊 mysql 的 MVCC","url":"/2020/04/26/聊聊-mysql-的-MVCC/"},{"title":"聊聊 Linux 下的 top 命令","url":"/2021/03/28/聊聊-Linux-下的-top-命令/"},{"title":"聊聊一次 brew update 引发的血案","url":"/2020/06/13/聊聊一次-brew-update-引发的血案/"},{"title":"聊聊厦门旅游的好与不好","url":"/2021/04/11/聊聊厦门旅游的好与不好/"},{"title":"聊聊Java中的单例模式","url":"/2019/12/21/聊聊Java中的单例模式/"},{"title":"聊聊我刚学会的应用诊断方法","url":"/2020/05/22/聊聊我刚学会的应用诊断方法/"},{"title":"聊聊 redis 缓存的应用问题","url":"/2021/01/31/聊聊-redis-缓存的应用问题/"},{"title":"这周末我又在老丈人家打了天小工","url":"/2020/08/30/这周末我又在老丈人家打了天小工/"},{"title":"闲聊下乘公交的用户体验","url":"/2021/02/28/闲聊下乘公交的用户体验/"},{"title":"聊聊 mysql 索引的一些细节","url":"/2020/12/27/聊聊-mysql-索引的一些细节/"},{"title":"聊聊那些加塞狗","url":"/2021/01/17/聊聊那些加塞狗/"},{"title":"AQS篇一","url":"/2021/02/14/AQS篇一/"},{"title":"mybatis 的缓存是怎么回事","url":"/2020/10/03/mybatis-的缓存是怎么回事/"},{"title":"redis数据结构介绍-第一部分 SDS,链表,字典","url":"/2019/12/26/redis数据结构介绍/"},{"title":"redis数据结构介绍六 快表","url":"/2020/01/22/redis数据结构介绍六/"},{"title":"介绍一下 RocketMQ","url":"/2020/06/21/介绍一下-RocketMQ/"},{"title":"聊聊 Dubbo 的容错机制","url":"/2020/11/22/聊聊-Dubbo-的容错机制/"},{"title":"聊聊我理解的分布式事务","url":"/2020/05/17/聊聊我理解的分布式事务/"},{"title":"AQS篇二 之 Condition 浅析笔记","url":"/2021/02/21/AQS-之-Condition-浅析笔记/"},{"title":"Filter, Interceptor, Aop, 啥, 啥, 啥? 这些都是啥?","url":"/2020/08/22/Filter-Intercepter-Aop-啥-啥-啥-这些都是啥/"},{"title":"redis系列介绍七-过期策略","url":"/2020/04/12/redis系列介绍七/"},{"title":"JVM源码分析之G1垃圾收集器分析一","url":"/2019/12/07/JVM-G1-Part-1/"},{"title":"redis系列介绍八-淘汰策略","url":"/2020/04/18/redis系列介绍八/"},{"title":"聊一下 RocketMQ 的 NameServer 源码","url":"/2020/07/05/聊一下-RocketMQ-的-NameServer-源码/"},{"title":"聊聊 RocketMQ 的 Broker 源码","url":"/2020/07/19/聊聊-RocketMQ-的-Broker-源码/"},{"title":"聊聊 Java 自带的那些*逆天*工具","url":"/2020/08/02/聊聊-Java-自带的那些逆天工具/"},{"title":"聊一下 RocketMQ 的 DefaultMQPushConsumer 源码","url":"/2020/06/26/聊一下-RocketMQ-的-Consumer/"}] \ No newline at end of file +[{"title":"村上春树《1Q84》读后感","url":"/2019/12/18/1Q84读后感/"},{"title":"2019年终总结","url":"/2020/02/01/2019年终总结/"},{"title":"2020年中总结","url":"/2020/07/11/2020年中总结/"},{"title":"34_Search_for_a_Range","url":"/2016/08/14/34-Search-for-a-Range/"},{"title":"AbstractQueuedSynchronizer","url":"/2019/09/23/AbstractQueuedSynchronizer/"},{"title":"add-two-number","url":"/2015/04/14/Add-Two-Number/"},{"title":"Apollo 的 value 注解是怎么自动更新的","url":"/2020/11/01/Apollo-的-value-注解是怎么自动更新的/"},{"title":"Clone Graph Part I","url":"/2014/12/30/Clone-Graph-Part-I/"},{"title":"Comparator使用小记","url":"/2020/04/05/Comparator使用小记/"},{"title":"G1收集器概述","url":"/2020/02/09/G1收集器概述/"},{"title":"Leetcode 104 二叉树的最大深度(Maximum Depth of Binary Tree) 题解分析","url":"/2020/10/25/Leetcode-104-二叉树的最大深度-Maximum-Depth-of-Binary-Tree-题解分析/"},{"title":"2020 年终总结","url":"/2021/03/31/2020-年终总结/"},{"title":"Leetcode 105 从前序与中序遍历序列构造二叉树(Construct Binary Tree from Preorder and Inorder Traversal) 题解分析","url":"/2020/12/13/Leetcode-105-从前序与中序遍历序列构造二叉树-Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal-题解分析/"},{"title":"Leetcode 2 Add Two Numbers 题解分析","url":"/2020/10/11/Leetcode-2-Add-Two-Numbers-题解分析/"},{"title":"Leetcode 121 买卖股票的最佳时机(Best Time to Buy and Sell Stock) 题解分析","url":"/2021/03/14/Leetcode-121-买卖股票的最佳时机-Best-Time-to-Buy-and-Sell-Stock-题解分析/"},{"title":"Leetcode 124 二叉树中的最大路径和(Binary Tree Maximum Path Sum) 题解分析","url":"/2021/01/24/Leetcode-124-二叉树中的最大路径和-Binary-Tree-Maximum-Path-Sum-题解分析/"},{"title":"Leetcode 3 Longest Substring Without Repeating Characters 题解分析","url":"/2020/09/20/Leetcode-3-Longest-Substring-Without-Repeating-Characters-题解分析/"},{"title":"leetcode no.3","url":"/2015/04/15/Leetcode-No-3/"},{"title":"Leetcode 155 最小栈(Min Stack) 题解分析","url":"/2020/12/06/Leetcode-155-最小栈-Min-Stack-题解分析/"},{"title":"Linux 下 grep 命令的一点小技巧","url":"/2020/08/06/Linux-下-grep-命令的一点小技巧/"},{"title":"MFC 模态对话框","url":"/2014/12/24/MFC 模态对话框/"},{"title":"Maven实用小技巧","url":"/2020/02/16/Maven实用小技巧/"},{"title":"Leetcode 234 回文链表(Palindrome Linked List) 题解分析","url":"/2020/11/15/Leetcode-234-回文联表-Palindrome-Linked-List-题解分析/"},{"title":"Leetcode 160 相交链表(intersection-of-two-linked-lists) 题解分析","url":"/2021/01/10/Leetcode-160-相交链表-intersection-of-two-linked-lists-题解分析/"},{"title":"Redis_分布式锁","url":"/2019/12/10/Redis-Part-1/"},{"title":"Number of 1 Bits","url":"/2015/03/11/Number-Of-1-Bits/"},{"title":"Reverse Bits","url":"/2015/03/11/Reverse-Bits/"},{"title":"Path Sum","url":"/2015/01/04/Path-Sum/"},{"title":"binary-watch","url":"/2016/09/29/binary-watch/"},{"title":"ambari-summary","url":"/2017/05/09/ambari-summary/"},{"title":"docker-mysql-cluster","url":"/2016/08/14/docker-mysql-cluster/"},{"title":"Reverse Integer","url":"/2015/03/13/Reverse-Integer/"},{"title":"docker比一般多一点的初学者介绍","url":"/2020/03/08/docker比一般多一点的初学者介绍/"},{"title":"two sum","url":"/2015/01/14/Two-Sum/"},{"title":"docker比一般多一点的初学者介绍三","url":"/2020/03/21/docker比一般多一点的初学者介绍三/"},{"title":"docker比一般多一点的初学者介绍二","url":"/2020/03/15/docker比一般多一点的初学者介绍二/"},{"title":"docker使用中发现的echo命令的一个小技巧及其他","url":"/2020/03/29/echo命令的一个小技巧/"},{"title":"gogs使用webhook部署react单页应用","url":"/2020/02/22/gogs使用webhook部署react单页应用/"},{"title":"invert-binary-tree","url":"/2015/06/22/invert-binary-tree/"},{"title":"minimum-size-subarray-sum-209","url":"/2016/10/11/minimum-size-subarray-sum-209/"},{"title":"C++ 指针使用中的一个小问题","url":"/2014/12/23/my-new-post/"},{"title":"mybatis 的 $ 和 # 是有啥区别","url":"/2020/09/06/mybatis-的-和-是有啥区别/"},{"title":"openresty","url":"/2019/06/18/openresty/"},{"title":"pcre-intro-and-a-simple-package","url":"/2015/01/16/pcre-intro-and-a-simple-package/"},{"title":"php-abstract-class-and-interface","url":"/2016/11/10/php-abstract-class-and-interface/"},{"title":"rabbitmq-tips","url":"/2017/04/25/rabbitmq-tips/"},{"title":"redis数据结构介绍三-第三部分 整数集合","url":"/2020/01/10/redis数据结构介绍三/"},{"title":"redis数据结构介绍二-第二部分 跳表","url":"/2020/01/04/redis数据结构介绍二/"},{"title":"redis数据结构介绍五-第五部分 对象","url":"/2020/01/20/redis数据结构介绍五/"},{"title":"redis数据结构介绍四-第四部分 压缩表","url":"/2020/01/19/redis数据结构介绍四/"},{"title":"rust学习笔记-所有权一","url":"/2021/04/18/rust学习笔记/"},{"title":"spark-little-tips","url":"/2017/03/28/spark-little-tips/"},{"title":"summary-ranges-228","url":"/2016/10/12/summary-ranges-228/"},{"title":"swoole-websocket-test","url":"/2016/07/13/swoole-websocket-test/"},{"title":"周末我在老丈人家打了天小工","url":"/2020/08/16/周末我在老丈人家打了天小工/"},{"title":"《垃圾回收算法手册读书》笔记之整理算法","url":"/2021/03/07/《垃圾回收算法手册读书》笔记之整理算法/"},{"title":"关于公共交通再吐个槽","url":"/2021/03/21/关于公共交通再吐个槽/"},{"title":"在老丈人家的小工记三","url":"/2020/09/13/在老丈人家的小工记三/"},{"title":"从清华美院学姐聊聊我们身边的恶人","url":"/2020/11/29/从清华美院学姐聊聊我们身边的恶人/"},{"title":"在老丈人家的小工记四","url":"/2020/09/26/在老丈人家的小工记四/"},{"title":"在老丈人家的小工记五","url":"/2020/10/18/在老丈人家的小工记五/"},{"title":"关于读书打卡与分享","url":"/2021/02/07/关于读书打卡与分享/"},{"title":"寄生虫观后感","url":"/2020/03/01/寄生虫观后感/"},{"title":"我是如何走上跑步这条不归路的","url":"/2020/07/26/我是如何走上跑步这条不归路的/"},{"title":"聊聊 Dubbo 的 SPI 续之自适应拓展","url":"/2020/06/06/聊聊-Dubbo-的-SPI-续之自适应拓展/"},{"title":"聊聊 Dubbo 的 SPI","url":"/2020/05/31/聊聊-Dubbo-的-SPI/"},{"title":"从丁仲礼被美国制裁聊点啥","url":"/2020/12/20/从丁仲礼被美国制裁聊点啥/"},{"title":"聊聊 Java 的类加载机制一","url":"/2020/11/08/聊聊-Java-的类加载机制/"},{"title":"聊聊 mysql 的 MVCC 续篇","url":"/2020/05/02/聊聊-mysql-的-MVCC-续篇/"},{"title":"聊聊 mysql 的 MVCC 续续篇之锁分析","url":"/2020/05/10/聊聊-mysql-的-MVCC-续续篇之加锁分析/"},{"title":"聊聊 mysql 的 MVCC","url":"/2020/04/26/聊聊-mysql-的-MVCC/"},{"title":"聊聊 Linux 下的 top 命令","url":"/2021/03/28/聊聊-Linux-下的-top-命令/"},{"title":"聊聊Java中的单例模式","url":"/2019/12/21/聊聊Java中的单例模式/"},{"title":"聊聊一次 brew update 引发的血案","url":"/2020/06/13/聊聊一次-brew-update-引发的血案/"},{"title":"聊聊我刚学会的应用诊断方法","url":"/2020/05/22/聊聊我刚学会的应用诊断方法/"},{"title":"聊聊 dubbo 的线程池","url":"/2021/04/04/聊聊-dubbo-的线程池/"},{"title":"这周末我又在老丈人家打了天小工","url":"/2020/08/30/这周末我又在老丈人家打了天小工/"},{"title":"聊聊厦门旅游的好与不好","url":"/2021/04/11/聊聊厦门旅游的好与不好/"},{"title":"聊聊 redis 缓存的应用问题","url":"/2021/01/31/聊聊-redis-缓存的应用问题/"},{"title":"聊聊 Java 的 equals 和 hashCode 方法","url":"/2021/01/03/聊聊-Java-的-equals-和-hashCode-方法/"},{"title":"聊聊 mysql 索引的一些细节","url":"/2020/12/27/聊聊-mysql-索引的一些细节/"},{"title":"聊聊那些加塞狗","url":"/2021/01/17/聊聊那些加塞狗/"},{"title":"闲聊下乘公交的用户体验","url":"/2021/02/28/闲聊下乘公交的用户体验/"},{"title":"AQS篇一","url":"/2021/02/14/AQS篇一/"},{"title":"mybatis 的缓存是怎么回事","url":"/2020/10/03/mybatis-的缓存是怎么回事/"},{"title":"redis数据结构介绍-第一部分 SDS,链表,字典","url":"/2019/12/26/redis数据结构介绍/"},{"title":"redis数据结构介绍六 快表","url":"/2020/01/22/redis数据结构介绍六/"},{"title":"介绍一下 RocketMQ","url":"/2020/06/21/介绍一下-RocketMQ/"},{"title":"聊聊 Dubbo 的容错机制","url":"/2020/11/22/聊聊-Dubbo-的容错机制/"},{"title":"聊聊我理解的分布式事务","url":"/2020/05/17/聊聊我理解的分布式事务/"},{"title":"AQS篇二 之 Condition 浅析笔记","url":"/2021/02/21/AQS-之-Condition-浅析笔记/"},{"title":"Filter, Interceptor, Aop, 啥, 啥, 啥? 这些都是啥?","url":"/2020/08/22/Filter-Intercepter-Aop-啥-啥-啥-这些都是啥/"},{"title":"redis系列介绍七-过期策略","url":"/2020/04/12/redis系列介绍七/"},{"title":"JVM源码分析之G1垃圾收集器分析一","url":"/2019/12/07/JVM-G1-Part-1/"},{"title":"redis系列介绍八-淘汰策略","url":"/2020/04/18/redis系列介绍八/"},{"title":"聊一下 RocketMQ 的 NameServer 源码","url":"/2020/07/05/聊一下-RocketMQ-的-NameServer-源码/"},{"title":"聊聊 RocketMQ 的 Broker 源码","url":"/2020/07/19/聊聊-RocketMQ-的-Broker-源码/"},{"title":"聊聊 Java 自带的那些*逆天*工具","url":"/2020/08/02/聊聊-Java-自带的那些逆天工具/"},{"title":"聊一下 RocketMQ 的 DefaultMQPushConsumer 源码","url":"/2020/06/26/聊一下-RocketMQ-的-Consumer/"}] \ No newline at end of file diff --git a/lib/pace/README.html b/lib/pace/README.html index af3fe85698..ce25a0be39 100644 --- a/lib/pace/README.html +++ b/lib/pace/README.html @@ -351,20 +351,20 @@ @@ -389,7 +389,7 @@
- +
diff --git a/page/10/index.html b/page/10/index.html index c544b79ee3..07d323bb23 100644 --- a/page/10/index.html +++ b/page/10/index.html @@ -203,6 +203,131 @@ +
+ + + + + +
+

+ + +

+ + +
+ + + + +
+ + +

熟悉我的人(谁熟悉你啊🙄)知道我以前写过 PHP,虽然现在在工作中没用到了,但是自己的一些小工具还是会用 PHP 来写,但是在 Mac 碰到了一个环境相关的问题,因为我也是个更新狂魔,用了 brew 之后因为 gfw 的原因,如果长时间不更新,有时候要装一个用它装一个软件的话,前置的更新耗时就会让人非常头大,所以我基本会隔天 update 一下,但是这样会带来一个很心烦的问题,就是像这样,因为我是要用一个固定版本的 PHP,如果一直升需要一直配扩展啥的也很麻烦,如果一直升级 PHP 到最新版可能会比较少碰到这个问题

+
1
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
+

这是什么鬼啊,然后我去这个目录下看了下,已经都是libicui18n.67.dylib了,而且它没有把原来的版本保留下来,首先这个是个叫 icu4c是啥玩意,谷歌了一下

+
+

ICU4C是ICU在C/C++平台下的版本, ICU(International Component for Unicode)是基于”IBM公共许可证”的,与开源组织合作研究的, 用于支持软件国际化的开源项目。ICU4C提供了C/C++平台强大的国际化开发能力,软件开发者几乎可以使用ICU4C解决任何国际化的问题,根据各地的风俗和语言习惯,实现对数字、货币、时间、日期、和消息的格式化、解析,对字符串进行大小写转换、整理、搜索和排序等功能,必须一提的是,ICU4C提供了强大的BIDI算法,对阿拉伯语等BIDI语言提供了完善的支持。

+
+

然后首先想到的解决方案就是能不能我使用brew install icu4c@64来重装下原来的版本,发现不行,并木有,之前的做法就只能是去网上把 64 的下载下来,然后放到这个目录,比较麻烦不智能,虽然没抱着希望在谷歌着,不过这次竟然给我找到了一个我认为非常 nice 的解决方案,因为是在 Stack Overflow 找到的,本着写给像我这样的小小白看的,那就稍微翻译一下
第一步,我们到 brew的目录下

+
1
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
+

这个可以理解为是 maven 的 pom 文件,不过有很多不同之处,使用ruby 写的,然后一个文件对应一个组件或者软件,那我们看下有个叫icu4c.rb的文件,
第二步看看它的提交历史

+
1
git log --follow icu4c.rb
+

在 git log 的海洋中寻找,寻找它的(64版本)的身影

第三步注意这三个红框,Stack Overflow 给出来的答案这一步是找到这个 commit id 直接切出一个新分支

+
1
git checkout -b icu4c-63 e7f0f10dc63b1dc1061d475f1a61d01b70ef2cb7
+

其实注意 commit id 旁边的红框,这个是有tag 的,可以直接

+
1
git checkout icu4c-64
+

PS: 因为我的问题是出在 64 的问题,Stack Overflow 回答的是 63 的,反正是一样的解决方法
第四部,切回去之后我们就可以用 brew 提供的基于文件的安装命令来重新装上 64 版本

+
1
brew reinstall ./icu4c.rb
+

然后就是第五步,切换版本

+
1
brew switch icu4c 64.2
+

最后把分支切回来

+
1
git checkout master
+

是不是感觉很厉害的解决方法,大佬还提供了一个更牛的,直接写个 zsh 方法

+
1
2
3
4
5
6
7
8
9
10
11
12
# zsh
function hiicu64() {
local last_dir=$(pwd)

cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git checkout icu4c-4
brew reinstall ./icu4c.rb
brew switch icu4c 64.2
git checkout master

cd $last_dir
}
+

对应自己的版本改改版本号就可以了,非常好用。

+ + +
+ + + + + + +
+
+
+
+ + + + + + +
@@ -675,125 +800,6 @@ - - - -
- - - - - -
-

- - -

- - -
- - - - -
- - -

看完前面两篇水文之后,感觉不得不来分析下 mysql 的锁了,其实前面说到幻读的时候是有个前提没提到的,比如一个select * from table1 where id = 1这种查询语句其实是不会加传说中的锁的,当然这里是指在 RR 或者 RC 隔离级别下,
看一段 mysql官方文档

-
-

SELECT ... FROM is a consistent read, reading a snapshot of the database and setting no locks unless the transaction isolation level is set to SERIALIZABLE. For SERIALIZABLE level, the search sets shared next-key locks on the index records it encounters. However, only an index record lock is required for statements that lock rows using a unique index to search for a unique row.

-
-

纯粹的这种一致性读,实际读取的是快照,也就是基于 read view 的读取方式,除非当前隔离级别是SERIALIZABLE
但是对于以下几类

-
    -
  • select * from table where ? lock in share mode;
  • -
  • select * from table where ? for update;
  • -
  • insert into table values (...);
  • -
  • update table set ? where ?;
  • -
  • delete from table where ?;
  • -
-

除了第一条是 S 锁之外,其他都是 X 排他锁,这边在顺带下,S 锁表示共享锁, X 表示独占锁,同为 S 锁之间不冲突,S 与 X,X 与 S,X 与 X 之间都冲突,也就是加了前者,后者就加不上了
我们知道对于 RC 级别会出现幻读现象,对于 RR 级别不会出现,主要的区别是 RR 级别下对于以上的加锁读取都根据情况加上了 gap 锁,那么是不是 RR 级别下以上所有的都是要加 gap 锁呢,当然不是
举个例子,RR 事务隔离级别下,table1 有个主键id 字段
select * from table1 where id = 10 for update
这条语句要加 gap 锁吗?
答案是不需要,这里其实算是我看了这么久的一点自己的理解,啥时候要加 gap 锁,判断的条件是根据我查询的数据是否会因为不加 gap 锁而出现数量的不一致,我上面这条查询语句,在什么情况下会出现查询结果数量不一致呢,只要在这条记录被更新或者删除的时候,有没有可能我第一次查出来一条,第二次变成两条了呢,不可能,因为是主键索引。
再变更下这个题的条件,当 id 不是主键,但是是唯一索引,这样需要怎么加锁,注意问题是怎么加锁,不是需不需要加 gap 锁,这里呢就是稍微延伸一下,把聚簇索引(主键索引)和二级索引带一下,当 id 不是主键,说明是个二级索引,但是它是唯一索引,体会下,首先对于 id = 10这个二级索引肯定要加锁,要不要锁 gap 呢,不用,因为是唯一索引,id = 10 只可能有这一条记录,然后呢,这样是不是就好了,还不行,因为啥,因为它是二级索引,对应的主键索引的记录才是真正的数据,万一被更新掉了咋办,所以在 id = 10 对应的主键索引上也需要加上锁(默认都是 record lock行锁),那主键索引上要不要加 gap 呢,也不用,也是精确定位到这一条记录
最后呢,当 id 不是主键,也不是唯一索引,只是个普通的索引,这里就需要大名鼎鼎的 gap 锁了,
是时候画个图了

其实核心的目的还是不让这个 id=10 的记录不会出现幻读,那么就需要在 id 这个索引上加上三个 gap 锁,主键索引上就不用了,在 id 索引上已经控制住了id = 10 不会出现幻读,主键索引上这两条对应的记录已经锁了,所以就这样 OK 了

- - -
- - - - - - -
-
-
-
- - - - @@ -903,7 +909,7 @@
- +
diff --git a/page/11/index.html b/page/11/index.html index 9b74f6c16e..0f0213a1d8 100644 --- a/page/11/index.html +++ b/page/11/index.html @@ -203,6 +203,125 @@ +
+ + + + + +
+

+ + +

+ + +
+ + + + +
+ + +

看完前面两篇水文之后,感觉不得不来分析下 mysql 的锁了,其实前面说到幻读的时候是有个前提没提到的,比如一个select * from table1 where id = 1这种查询语句其实是不会加传说中的锁的,当然这里是指在 RR 或者 RC 隔离级别下,
看一段 mysql官方文档

+
+

SELECT ... FROM is a consistent read, reading a snapshot of the database and setting no locks unless the transaction isolation level is set to SERIALIZABLE. For SERIALIZABLE level, the search sets shared next-key locks on the index records it encounters. However, only an index record lock is required for statements that lock rows using a unique index to search for a unique row.

+
+

纯粹的这种一致性读,实际读取的是快照,也就是基于 read view 的读取方式,除非当前隔离级别是SERIALIZABLE
但是对于以下几类

+
    +
  • select * from table where ? lock in share mode;
  • +
  • select * from table where ? for update;
  • +
  • insert into table values (...);
  • +
  • update table set ? where ?;
  • +
  • delete from table where ?;
  • +
+

除了第一条是 S 锁之外,其他都是 X 排他锁,这边在顺带下,S 锁表示共享锁, X 表示独占锁,同为 S 锁之间不冲突,S 与 X,X 与 S,X 与 X 之间都冲突,也就是加了前者,后者就加不上了
我们知道对于 RC 级别会出现幻读现象,对于 RR 级别不会出现,主要的区别是 RR 级别下对于以上的加锁读取都根据情况加上了 gap 锁,那么是不是 RR 级别下以上所有的都是要加 gap 锁呢,当然不是
举个例子,RR 事务隔离级别下,table1 有个主键id 字段
select * from table1 where id = 10 for update
这条语句要加 gap 锁吗?
答案是不需要,这里其实算是我看了这么久的一点自己的理解,啥时候要加 gap 锁,判断的条件是根据我查询的数据是否会因为不加 gap 锁而出现数量的不一致,我上面这条查询语句,在什么情况下会出现查询结果数量不一致呢,只要在这条记录被更新或者删除的时候,有没有可能我第一次查出来一条,第二次变成两条了呢,不可能,因为是主键索引。
再变更下这个题的条件,当 id 不是主键,但是是唯一索引,这样需要怎么加锁,注意问题是怎么加锁,不是需不需要加 gap 锁,这里呢就是稍微延伸一下,把聚簇索引(主键索引)和二级索引带一下,当 id 不是主键,说明是个二级索引,但是它是唯一索引,体会下,首先对于 id = 10这个二级索引肯定要加锁,要不要锁 gap 呢,不用,因为是唯一索引,id = 10 只可能有这一条记录,然后呢,这样是不是就好了,还不行,因为啥,因为它是二级索引,对应的主键索引的记录才是真正的数据,万一被更新掉了咋办,所以在 id = 10 对应的主键索引上也需要加上锁(默认都是 record lock行锁),那主键索引上要不要加 gap 呢,也不用,也是精确定位到这一条记录
最后呢,当 id 不是主键,也不是唯一索引,只是个普通的索引,这里就需要大名鼎鼎的 gap 锁了,
是时候画个图了

其实核心的目的还是不让这个 id=10 的记录不会出现幻读,那么就需要在 id 这个索引上加上三个 gap 锁,主键索引上就不用了,在 id 索引上已经控制住了id = 10 不会出现幻读,主键索引上这两条对应的记录已经锁了,所以就这样 OK 了

+ + +
+ + + + + + +
+
+
+
+ + + + + + +
@@ -247,11 +366,11 @@ , - + , - + , @@ -367,11 +486,11 @@ , - + , - + , @@ -712,117 +831,6 @@ - - - -
- - - - - -
-

- - -

- - -
- - - - -
- - -

在Java8的stream之前,将对象进行排序的时候,可能需要对象实现Comparable接口,或者自己实现一个Comparator,

-

比如这样子

-

我的对象是Entity

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Entity {

private Long id;

private Long sortValue;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getSortValue() {
return sortValue;
}

public void setSortValue(Long sortValue) {
this.sortValue = sortValue;
}
}
- -

Comparator

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class MyComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
Entity e1 = (Entity) o1;
Entity e2 = (Entity) o2;
if (e1.getSortValue() < e2.getSortValue()) {
return -1;
} else if (e1.getSortValue().equals(e2.getSortValue())) {
return 0;
} else {
return 1;
}
}
}
- -

比较代码

-
1
2
3
4
5
6
7
8
9
10
11
12
13
private static MyComparator myComparator = new MyComparator();

public static void main(String[] args) {
List<Entity> list = new ArrayList<Entity>();
Entity e1 = new Entity();
e1.setId(1L);
e1.setSortValue(1L);
list.add(e1);
Entity e2 = new Entity();
e2.setId(2L);
e2.setSortValue(null);
list.add(e2);
Collections.sort(list, myComparator);
- -

看到这里的e2的排序值是null,在Comparator中如果要正常运行的话,就得判空之类的,这里有两点需要,一个是不想写这个MyComparator,然后也没那么好排除掉list里排序值,那么有什么办法能解决这种问题呢,应该说java的这方面真的是很强大

-

-

看一下nullsFirst的实现

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
final static class NullComparator<T> implements Comparator<T>, Serializable {
private static final long serialVersionUID = -7569533591570686392L;
private final boolean nullFirst;
// if null, non-null Ts are considered equal
private final Comparator<T> real;

@SuppressWarnings("unchecked")
NullComparator(boolean nullFirst, Comparator<? super T> real) {
this.nullFirst = nullFirst;
this.real = (Comparator<T>) real;
}

@Override
public int compare(T a, T b) {
if (a == null) {
return (b == null) ? 0 : (nullFirst ? -1 : 1);
} else if (b == null) {
return nullFirst ? 1: -1;
} else {
return (real == null) ? 0 : real.compare(a, b);
}
}
- -

核心代码就是下面这段,其实就是帮我们把前面要做的事情做掉了,是不是挺方便的,小记一下哈

- - -
- - - - - - -
-
-
-
- - - - @@ -932,7 +940,7 @@
- +
diff --git a/page/12/index.html b/page/12/index.html index 59cab4cab8..2e2527dbfa 100644 --- a/page/12/index.html +++ b/page/12/index.html @@ -203,6 +203,117 @@ +
+ + + + + +
+

+ + +

+ + +
+ + + + +
+ + +

在Java8的stream之前,将对象进行排序的时候,可能需要对象实现Comparable接口,或者自己实现一个Comparator,

+

比如这样子

+

我的对象是Entity

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Entity {

private Long id;

private Long sortValue;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getSortValue() {
return sortValue;
}

public void setSortValue(Long sortValue) {
this.sortValue = sortValue;
}
}
+ +

Comparator

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class MyComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
Entity e1 = (Entity) o1;
Entity e2 = (Entity) o2;
if (e1.getSortValue() < e2.getSortValue()) {
return -1;
} else if (e1.getSortValue().equals(e2.getSortValue())) {
return 0;
} else {
return 1;
}
}
}
+ +

比较代码

+
1
2
3
4
5
6
7
8
9
10
11
12
13
private static MyComparator myComparator = new MyComparator();

public static void main(String[] args) {
List<Entity> list = new ArrayList<Entity>();
Entity e1 = new Entity();
e1.setId(1L);
e1.setSortValue(1L);
list.add(e1);
Entity e2 = new Entity();
e2.setId(2L);
e2.setSortValue(null);
list.add(e2);
Collections.sort(list, myComparator);
+ +

看到这里的e2的排序值是null,在Comparator中如果要正常运行的话,就得判空之类的,这里有两点需要,一个是不想写这个MyComparator,然后也没那么好排除掉list里排序值,那么有什么办法能解决这种问题呢,应该说java的这方面真的是很强大

+

+

看一下nullsFirst的实现

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
final static class NullComparator<T> implements Comparator<T>, Serializable {
private static final long serialVersionUID = -7569533591570686392L;
private final boolean nullFirst;
// if null, non-null Ts are considered equal
private final Comparator<T> real;

@SuppressWarnings("unchecked")
NullComparator(boolean nullFirst, Comparator<? super T> real) {
this.nullFirst = nullFirst;
this.real = (Comparator<T>) real;
}

@Override
public int compare(T a, T b) {
if (a == null) {
return (b == null) ? 0 : (nullFirst ? -1 : 1);
} else if (b == null) {
return nullFirst ? 1: -1;
} else {
return (real == null) ? 0 : real.compare(a, b);
}
}
+ +

核心代码就是下面这段,其实就是帮我们把前面要做的事情做掉了,是不是挺方便的,小记一下哈

+ + +
+ + + + + + +
+
+
+
+ + + + + + +
@@ -670,110 +781,6 @@ - - - -
- - - - - -
-

- - -

- - -
- - - - -
- - -

寄生虫这部电影在获得奥斯卡之前就有关注了,豆瓣评分很高,一开始看到这个片名以为是像《铁线虫入侵》那种灾难片,后来看到男主,宋康昊,也是老面孔了,从高中时候在学校操场组织看的《汉江怪物》,有点二的感觉,后来在大学寝室电脑上重新看的时候,室友跟我说是韩国国宝级演员,真人不可貌相,感觉是个呆子的形象。

-

但是你说这不是个灾难片,而是个反映社会问题的,就业比较容易往这个方向猜,只是剧情会是怎么样的,一时也没啥头绪,后来不知道哪里看了下一个剧情透露,是一个穷人给富人做家教,然后把自己一家都带进富人家,如果是这样的话可能会把这个怎么带进去作为一个主线,不过事实告诉我,这没那么重要,从第一步朋友的介绍,就显得无比顺利,要去当家教了,作为一个穷成这样的人,瞬间转变成一个衣着得体,言行举止都没让富人家看出破绽的延世大学学生,这真的挺难让人理解,所谓江山易改,本性难移,还有就是这人也正好有那么好能力去辅导,并且诡异的是,多惠也是瞬间就喜欢上了男主,多惠跟将男主介绍给她做家教,也就是多惠原来的家教敏赫,应该也有不少的相处时间,这变了有点大了吧,当然这里也可能因为时长需要,如果说这一点是因为时长,那可能我所有的槽点都是因为这个吧,因为我理解的应该是把家里的人如何一步步地带进富人家,这应该是整个剧情的一个需要更多铺垫去克服这个矛盾点,有时候也想过如果我去当导演,是能拍出个啥,没这个机会,可能有也会是很扯淡的,当然这也不能阻拦我谈谈对这个点的一些看法,毕竟评价一台电冰箱不是说我必须得自己会制冷对吧,这大概是我觉得这个电影的第一个槽点,接下去接二连三的,就是我说的这个最核心的矛盾点,不知道谁说过,这种影视剧应该是源自于生活又高于生活,越是好的作品,越要接近生活,这样子才更能有感同身受。

-

接下去的点是金基宇介绍金基婷去给多颂当美术家教,这一步又是我理解的败笔吧,就怎么说呢,没什么铺垫,突然从一个社会底层的穷姑娘,转变成一个气场爆表,把富人家太太唬得一愣一愣的,如果说富太太是比较简单无脑的,那富人自己应该是比较有见识而且是做 IT 的,给自己儿子女儿做家教的,查查底细也很正常吧,但是啥都没有,然后呢,她又开始耍司机的心机了,真的是莫名其妙了,司机真的很惨,窈窕淑女君子好逑,而且这个操作也让我摸不着头脑,这是多腹黑并且有经验才会这么操作,脱内裤真的是让我看得一愣愣的,更看得我一愣一愣的,富人竟然也完全按着这个思路去想了,完全没有别的可能呢,甚至可以去查下行车记录仪或者怎样的,或者有没有毛发体液啥的去检验下,毕竟金基婷也乘坐过这辆车,但是最最让我不懂的还是脱内裤这个操作,究竟是什么样的人才会的呢,值得思考。

-

金基泽和忠淑的点也是比较奇怪,首先是金基泽,引起最后那个杀人事件的一个由头,大部分观点都是人为朴社长在之前跟老婆啪啪啪的时候说金基泽的身上有股乘地铁的人的味道,简而言之就是穷人的味道,还有去雯光丈夫身下拿钥匙是对金基泽和雯光丈夫身上的味道的鄙夷,可是这个原因真的站不住脚,即使是同样经济水平,如果身上有比较重的异味,背后讨论下,或者闻到了比较重的味道,有不适的表情和动作很正常吧,像雯光丈夫,在地下室里呆了那么久,身上有异味并且比较重太正常了,就跟在厕所呆久了不会觉得味道大,但是从没味道的地方一进有点味道的厕所就会觉得异样,略尴尬的理由;再说忠淑呢,感觉是太厉害了,能胜任这么一家有钱人的各种挑剔的饮食口味要求的保姆职位,也是让人看懵逼了,看到了不禁想到一个问题,这家人开头是那么地穷,不堪,突然转变成这么地像骗子家族,如果有这么好的骗人能力,应该不会到这种地步吧,如果真的是那么穷,没能力,没志气,又怎么会突然变成这么厉害呢,一家人各司其职,把富人家唬得团团转,而这个前提是,这些人的确能胜任这四个位置,这就是我非常不能理解的点。

-

然后说回这个标题,寄生虫,不知道是不是翻译过来不准确,如果真的是叫寄生虫的话,这个寄生虫智商未免也太低了,没有像新冠那样机制,致死率低一点,传染能力强一点,潜伏期也能传染,这个寄生虫第一次受到免疫系统的攻击就自爆了;还有呢,作为一个社会比较低层的打工者,乡下人,对这个审题也是不太审的清,是指这一家人是社会的寄生虫,不思进取,并且死的应该,富人是傻白甜,又有钱又善良,这是给有钱人洗地了还是啥,这个奥斯卡真不知道是怎么得的,总觉得奥斯卡,甚至低一点,豆瓣,得奖的,评分高的都是被一群“精英党”把持的,有黑人主角的,得分高;有同性恋的,得分高;结局惨的,得分高;看不懂的,得分高;就像肖申克的救赎,真不知道是哪里好了,最近看了关于明朝那些事的三杨,杨溥的经历应该比这个厉害吧,可是外国人看不懂,就像外国人不懂中国为什么有反分裂国家法,经历了鸦片战争,八国联军,抗日战争等等,其实跟外国对于黑人的权益的问题,因为有南北战争,所以极度重视这个问题,相应的中国也有自己的历史,请理解。

-

简而言之我对寄生虫的评分大概 5~6 分吧。

- - -
- - - - - - -
-
-
-
- - - - @@ -883,7 +890,7 @@
- +
diff --git a/page/13/index.html b/page/13/index.html index 5eef78a1ae..106c74b8c1 100644 --- a/page/13/index.html +++ b/page/13/index.html @@ -203,6 +203,110 @@ +
+ + + + + +
+

+ + +

+ + +
+ + + + +
+ + +

寄生虫这部电影在获得奥斯卡之前就有关注了,豆瓣评分很高,一开始看到这个片名以为是像《铁线虫入侵》那种灾难片,后来看到男主,宋康昊,也是老面孔了,从高中时候在学校操场组织看的《汉江怪物》,有点二的感觉,后来在大学寝室电脑上重新看的时候,室友跟我说是韩国国宝级演员,真人不可貌相,感觉是个呆子的形象。

+

但是你说这不是个灾难片,而是个反映社会问题的,就业比较容易往这个方向猜,只是剧情会是怎么样的,一时也没啥头绪,后来不知道哪里看了下一个剧情透露,是一个穷人给富人做家教,然后把自己一家都带进富人家,如果是这样的话可能会把这个怎么带进去作为一个主线,不过事实告诉我,这没那么重要,从第一步朋友的介绍,就显得无比顺利,要去当家教了,作为一个穷成这样的人,瞬间转变成一个衣着得体,言行举止都没让富人家看出破绽的延世大学学生,这真的挺难让人理解,所谓江山易改,本性难移,还有就是这人也正好有那么好能力去辅导,并且诡异的是,多惠也是瞬间就喜欢上了男主,多惠跟将男主介绍给她做家教,也就是多惠原来的家教敏赫,应该也有不少的相处时间,这变了有点大了吧,当然这里也可能因为时长需要,如果说这一点是因为时长,那可能我所有的槽点都是因为这个吧,因为我理解的应该是把家里的人如何一步步地带进富人家,这应该是整个剧情的一个需要更多铺垫去克服这个矛盾点,有时候也想过如果我去当导演,是能拍出个啥,没这个机会,可能有也会是很扯淡的,当然这也不能阻拦我谈谈对这个点的一些看法,毕竟评价一台电冰箱不是说我必须得自己会制冷对吧,这大概是我觉得这个电影的第一个槽点,接下去接二连三的,就是我说的这个最核心的矛盾点,不知道谁说过,这种影视剧应该是源自于生活又高于生活,越是好的作品,越要接近生活,这样子才更能有感同身受。

+

接下去的点是金基宇介绍金基婷去给多颂当美术家教,这一步又是我理解的败笔吧,就怎么说呢,没什么铺垫,突然从一个社会底层的穷姑娘,转变成一个气场爆表,把富人家太太唬得一愣一愣的,如果说富太太是比较简单无脑的,那富人自己应该是比较有见识而且是做 IT 的,给自己儿子女儿做家教的,查查底细也很正常吧,但是啥都没有,然后呢,她又开始耍司机的心机了,真的是莫名其妙了,司机真的很惨,窈窕淑女君子好逑,而且这个操作也让我摸不着头脑,这是多腹黑并且有经验才会这么操作,脱内裤真的是让我看得一愣愣的,更看得我一愣一愣的,富人竟然也完全按着这个思路去想了,完全没有别的可能呢,甚至可以去查下行车记录仪或者怎样的,或者有没有毛发体液啥的去检验下,毕竟金基婷也乘坐过这辆车,但是最最让我不懂的还是脱内裤这个操作,究竟是什么样的人才会的呢,值得思考。

+

金基泽和忠淑的点也是比较奇怪,首先是金基泽,引起最后那个杀人事件的一个由头,大部分观点都是人为朴社长在之前跟老婆啪啪啪的时候说金基泽的身上有股乘地铁的人的味道,简而言之就是穷人的味道,还有去雯光丈夫身下拿钥匙是对金基泽和雯光丈夫身上的味道的鄙夷,可是这个原因真的站不住脚,即使是同样经济水平,如果身上有比较重的异味,背后讨论下,或者闻到了比较重的味道,有不适的表情和动作很正常吧,像雯光丈夫,在地下室里呆了那么久,身上有异味并且比较重太正常了,就跟在厕所呆久了不会觉得味道大,但是从没味道的地方一进有点味道的厕所就会觉得异样,略尴尬的理由;再说忠淑呢,感觉是太厉害了,能胜任这么一家有钱人的各种挑剔的饮食口味要求的保姆职位,也是让人看懵逼了,看到了不禁想到一个问题,这家人开头是那么地穷,不堪,突然转变成这么地像骗子家族,如果有这么好的骗人能力,应该不会到这种地步吧,如果真的是那么穷,没能力,没志气,又怎么会突然变成这么厉害呢,一家人各司其职,把富人家唬得团团转,而这个前提是,这些人的确能胜任这四个位置,这就是我非常不能理解的点。

+

然后说回这个标题,寄生虫,不知道是不是翻译过来不准确,如果真的是叫寄生虫的话,这个寄生虫智商未免也太低了,没有像新冠那样机制,致死率低一点,传染能力强一点,潜伏期也能传染,这个寄生虫第一次受到免疫系统的攻击就自爆了;还有呢,作为一个社会比较低层的打工者,乡下人,对这个审题也是不太审的清,是指这一家人是社会的寄生虫,不思进取,并且死的应该,富人是傻白甜,又有钱又善良,这是给有钱人洗地了还是啥,这个奥斯卡真不知道是怎么得的,总觉得奥斯卡,甚至低一点,豆瓣,得奖的,评分高的都是被一群“精英党”把持的,有黑人主角的,得分高;有同性恋的,得分高;结局惨的,得分高;看不懂的,得分高;就像肖申克的救赎,真不知道是哪里好了,最近看了关于明朝那些事的三杨,杨溥的经历应该比这个厉害吧,可是外国人看不懂,就像外国人不懂中国为什么有反分裂国家法,经历了鸦片战争,八国联军,抗日战争等等,其实跟外国对于黑人的权益的问题,因为有南北战争,所以极度重视这个问题,相应的中国也有自己的历史,请理解。

+

简而言之我对寄生虫的评分大概 5~6 分吧。

+ + +
+ + + + + + +
+
+
+
+ + + + + + +
@@ -660,142 +764,6 @@ - - - -
- - - - - -
-

- - -

- - -
- - - - -
- - -

这应该是 redis 系列的最后一篇了,讲下快表,其实最前面讲的链表在早先的 redis 版本中也作为 list 的数据结构使用过,但是单纯的链表的缺陷之前也说了,插入便利,但是空间利用率低,并且不能进行二分查找等,检索效率低,ziplist 压缩表的产生也是同理,希望获得更好的性能,包括存储空间和访问性能等,原来我也不懂这个快表要怎么快,然后明白了一个道理,其实并没有什么银弹,只是大牛们会在适合的时候使用最适合的数据结构来实现性能的最大化,这里面有一招就是不同数据结构的组合调整,比如 Java 中的 HashMap,在链表节点数大于 8 时会转变成红黑树,以此提高访问效率,不费话了,回到快表,quicklist,这个数据结构主要使用在 list 类型中,如果我说其实这个 quicklist 就是个链表,可能大家不太会相信,但是事实上的确可以认为 quicklist 是个双向链表,看下代码

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* quicklistNode is a 32 byte struct describing a ziplist for a quicklist.
* We use bit fields keep the quicklistNode at 32 bytes.
* count: 16 bits, max 65536 (max zl bytes is 65k, so max count actually < 32k).
* encoding: 2 bits, RAW=1, LZF=2.
* container: 2 bits, NONE=1, ZIPLIST=2.
* recompress: 1 bit, bool, true if node is temporarry decompressed for usage.
* attempted_compress: 1 bit, boolean, used for verifying during testing.
* extra: 10 bits, free for future use; pads out the remainder of 32 bits */
typedef struct quicklistNode {
struct quicklistNode *prev;
struct quicklistNode *next;
unsigned char *zl;
unsigned int sz; /* ziplist size in bytes */
unsigned int count : 16; /* count of items in ziplist */
unsigned int encoding : 2; /* RAW==1 or LZF==2 */
unsigned int container : 2; /* NONE==1 or ZIPLIST==2 */
unsigned int recompress : 1; /* was this node previous compressed? */
unsigned int attempted_compress : 1; /* node can't compress; too small */
unsigned int extra : 10; /* more bits to steal for future usage */
} quicklistNode;

/* quicklistLZF is a 4+N byte struct holding 'sz' followed by 'compressed'.
* 'sz' is byte length of 'compressed' field.
* 'compressed' is LZF data with total (compressed) length 'sz'
* NOTE: uncompressed length is stored in quicklistNode->sz.
* When quicklistNode->zl is compressed, node->zl points to a quicklistLZF */
typedef struct quicklistLZF {
unsigned int sz; /* LZF size in bytes*/
char compressed[];
} quicklistLZF;

/* quicklist is a 40 byte struct (on 64-bit systems) describing a quicklist.
* 'count' is the number of total entries.
* 'len' is the number of quicklist nodes.
* 'compress' is: -1 if compression disabled, otherwise it's the number
* of quicklistNodes to leave uncompressed at ends of quicklist.
* 'fill' is the user-requested (or default) fill factor. */
typedef struct quicklist {
quicklistNode *head;
quicklistNode *tail;
unsigned long count; /* total count of all entries in all ziplists */
unsigned long len; /* number of quicklistNodes */
int fill : 16; /* fill factor for individual nodes */
unsigned int compress : 16; /* depth of end nodes not to compress;0=off */
} quicklist;
-

粗略看下,quicklist 里有 head,tail, quicklistNode里有 prev,next 指针,是不是有链表的基本轮廓了,那么为啥这玩意要称为快表呢,快在哪,关键就在这个unsigned char *zl;zl 是不是前面又看到过,就是 ziplist ,这是什么鬼,链表里用压缩表,这不套娃么,先别急,回顾下前面说的 ziplist,ziplist 有哪些特点,内存利用率高,可以从表头快速定位到尾节点,节点可以从后往前找,但是有个缺点,就是从中间插入的效率比较低,需要整体往后移,这个其实是普通数组的优化版,但还是有数组的一些劣势,所以要真的快,是不是可以将链表跟数组真的结合起来。

-

ziplist

这里有两个 redis 的配置参数,list-max-ziplist-sizelist-compress-depth,先来说第一个,既然快表是将链表跟压缩表数组结合起来使用,那么具体怎么用呢,比如我有一个 10 个元素的 list,那具体怎么放,每个 quicklistNode 里放多大的 ziplist,假如每个快表节点的 ziplist 只放一个元素,那么其实这就退化成了一个链表,如果 10 个元素放在一个 quicklistNode 的 ziplist 里,那就退化成了一个 ziplist,所以有了这个 list-max-ziplist-size,而且它还比较牛,能取正负值,当是正值时,对应的就是每个 quicklistNode 的 ziplist 中的元素个数,比如配置了 list-max-ziplist-size = 5,那么我刚才的 10 个元素的 list 就是一个两个 quicklistNode 组成的快表,每个 quicklistNode 中的 ziplist 包含了五个元素,当 list-max-ziplist-size取负值的时候,它限制了 ziplist 的字节数

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
size_t offset = (-fill) - 1;
if (offset < (sizeof(optimization_level) / sizeof(*optimization_level))) {
if (sz <= optimization_level[offset]) {
return 1;
} else {
return 0;
}
} else {
return 0;
}

/* Optimization levels for size-based filling */
static const size_t optimization_level[] = {4096, 8192, 16384, 32768, 65536};

/* Create a new quicklist.
* Free with quicklistRelease(). */
quicklist *quicklistCreate(void) {
struct quicklist *quicklist;

quicklist = zmalloc(sizeof(*quicklist));
quicklist->head = quicklist->tail = NULL;
quicklist->len = 0;
quicklist->count = 0;
quicklist->compress = 0;
quicklist->fill = -2;
return quicklist;
}
-

这个 fill 就是传进来的 list-max-ziplist-size, 具体对应的就是

-
    -
  • -5: 每个quicklist节点上的ziplist大小不能超过64 Kb。(注:1kb => 1024 bytes)
  • -
  • -4: 每个quicklist节点上的ziplist大小不能超过32 Kb。
  • -
  • -3: 每个quicklist节点上的ziplist大小不能超过16 Kb。
  • -
  • -2: 每个quicklist节点上的ziplist大小不能超过8 Kb。(-2是Redis给出的默认值)也就是上面的 quicklist->fill = -2;
  • -
  • -1: 每个quicklist节点上的ziplist大小不能超过4 Kb。
  • -
-

压缩

list-compress-depth这个参数呢是用来配置压缩的,等等压缩是为啥,不是里面已经是压缩表了么,大牛们就是为了性能殚精竭虑,这里考虑到的是一个场景,一般状况下,list 都是两端的访问频率比较高,那么是不是可以对中间的数据进行压缩,那么这个参数就是用来表示

-
1
/* depth of end nodes not to compress;0=off */
-
    -
  • 0,代表不压缩,默认值
  • -
  • 1,两端各一个节点不压缩
  • -
  • 2,两端各两个节点不压缩
  • -
  • … 依次类推
    压缩后的 ziplist 就会变成 quicklistLZF,然后替换 zl 指针,这里使用的是 LZF 压缩算法,压缩后的 quicklistLZF 中的 compressed 也是个柔性数组,压缩后的 ziplist 整个就放进这个柔性数组
  • -
-

插入过程

简单说下插入元素的过程

-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Wrapper to allow argument-based switching between HEAD/TAIL pop */
void quicklistPush(quicklist *quicklist, void *value, const size_t sz,
int where) {
if (where == QUICKLIST_HEAD) {
quicklistPushHead(quicklist, value, sz);
} else if (where == QUICKLIST_TAIL) {
quicklistPushTail(quicklist, value, sz);
}
}

/* Add new entry to head node of quicklist.
*
* Returns 0 if used existing head.
* Returns 1 if new head created. */
int quicklistPushHead(quicklist *quicklist, void *value, size_t sz) {
quicklistNode *orig_head = quicklist->head;
if (likely(
_quicklistNodeAllowInsert(quicklist->head, quicklist->fill, sz))) {
quicklist->head->zl =
ziplistPush(quicklist->head->zl, value, sz, ZIPLIST_HEAD);
quicklistNodeUpdateSz(quicklist->head);
} else {
quicklistNode *node = quicklistCreateNode();
node->zl = ziplistPush(ziplistNew(), value, sz, ZIPLIST_HEAD);

quicklistNodeUpdateSz(node);
_quicklistInsertNodeBefore(quicklist, quicklist->head, node);
}
quicklist->count++;
quicklist->head->count++;
return (orig_head != quicklist->head);
}

/* Add new entry to tail node of quicklist.
*
* Returns 0 if used existing tail.
* Returns 1 if new tail created. */
int quicklistPushTail(quicklist *quicklist, void *value, size_t sz) {
quicklistNode *orig_tail = quicklist->tail;
if (likely(
_quicklistNodeAllowInsert(quicklist->tail, quicklist->fill, sz))) {
quicklist->tail->zl =
ziplistPush(quicklist->tail->zl, value, sz, ZIPLIST_TAIL);
quicklistNodeUpdateSz(quicklist->tail);
} else {
quicklistNode *node = quicklistCreateNode();
node->zl = ziplistPush(ziplistNew(), value, sz, ZIPLIST_TAIL);

quicklistNodeUpdateSz(node);
_quicklistInsertNodeAfter(quicklist, quicklist->tail, node);
}
quicklist->count++;
quicklist->tail->count++;
return (orig_tail != quicklist->tail);
}

/* Wrappers for node inserting around existing node. */
REDIS_STATIC void _quicklistInsertNodeBefore(quicklist *quicklist,
quicklistNode *old_node,
quicklistNode *new_node) {
__quicklistInsertNode(quicklist, old_node, new_node, 0);
}

REDIS_STATIC void _quicklistInsertNodeAfter(quicklist *quicklist,
quicklistNode *old_node,
quicklistNode *new_node) {
__quicklistInsertNode(quicklist, old_node, new_node, 1);
}

/* Insert 'new_node' after 'old_node' if 'after' is 1.
* Insert 'new_node' before 'old_node' if 'after' is 0.
* Note: 'new_node' is *always* uncompressed, so if we assign it to
* head or tail, we do not need to uncompress it. */
REDIS_STATIC void __quicklistInsertNode(quicklist *quicklist,
quicklistNode *old_node,
quicklistNode *new_node, int after) {
if (after) {
new_node->prev = old_node;
if (old_node) {
new_node->next = old_node->next;
if (old_node->next)
old_node->next->prev = new_node;
old_node->next = new_node;
}
if (quicklist->tail == old_node)
quicklist->tail = new_node;
} else {
new_node->next = old_node;
if (old_node) {
new_node->prev = old_node->prev;
if (old_node->prev)
old_node->prev->next = new_node;
old_node->prev = new_node;
}
if (quicklist->head == old_node)
quicklist->head = new_node;
}
/* If this insert creates the only element so far, initialize head/tail. */
if (quicklist->len == 0) {
quicklist->head = quicklist->tail = new_node;
}

if (old_node)
quicklistCompress(quicklist, old_node);

quicklist->len++;
}
-

前面第一步先根据插入的是头还是尾选择不同的 push 函数,quicklistPushHead 或者 quicklistPushTail,举例分析下从头插入的 quicklistPushHead,先判断当前的 quicklistNode 节点还能不能允许再往 ziplist 里添加元素,如果可以就添加,如果不允许就新建一个 quicklistNode,然后调用 _quicklistInsertNodeBefore 将节点插进去,具体插入quicklist节点的操作类似链表的插入。

- - -
- - - - - - -
-
-
-
- - - - @@ -905,7 +873,7 @@
- +
diff --git a/page/14/index.html b/page/14/index.html index f6b9ea7f9d..1df3e19d5d 100644 --- a/page/14/index.html +++ b/page/14/index.html @@ -204,7 +204,7 @@
- +