-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1283 lines (898 loc) · 47 KB
/
index.html
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
<script id="hexo-configurations">
var NexT = window.NexT || {};
var CONFIG = {
hostname: new URL('https://shiro-umi.github.io').hostname,
root: '/',
scheme: 'Muse',
version: '7.6.0',
exturl: false,
sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
copycode: {"enable":false,"show_result":false,"style":null},
back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
bookmark: {"enable":false,"color":"#222","save":"auto"},
fancybox: false,
mediumzoom: false,
lazyload: false,
pangu: false,
algolia: {
appID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
},
localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
path: '',
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
};
</script>
<meta property="og:type" content="website">
<meta property="og:title" content="ShiroUmi">
<meta property="og:url" content="https://shiro-umi.github.io/index.html">
<meta property="og:site_name" content="ShiroUmi">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Shiro-umi">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://shiro-umi.github.io/">
<script id="page-configurations">
// https://hexo.io/docs/variables.html
CONFIG.page = {
sidebar: "",
isHome: true,
isPost: false,
isPage: false,
isArchive: false
};
</script>
<title>ShiroUmi</title>
<noscript>
<style>
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-header { opacity: initial; }
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage">
<div class="container use-motion">
<div class="headband"></div>
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-meta">
<div>
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">ShiroUmi</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">三流码奴的自我救赎</p>
</div>
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏">
<span class="toggle-line toggle-line-first"></span>
<span class="toggle-line toggle-line-middle"></span>
<span class="toggle-line toggle-line-last"></span>
</div>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>
</li>
</ul>
</nav>
</div>
</header>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<main class="main">
<div class="main-inner">
<div class="content-wrap">
<div class="content">
<div class="posts-expand">
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2021/05/10/JetpackCompose-Composer/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2021/05/10/JetpackCompose-Composer/" class="post-title-link" itemprop="url">Jetpack Compose 核心组件 - Composer</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-05-10 11:50:36" itemprop="dateCreated datePublished" datetime="2021-05-10T11:50:36+08:00">2021-05-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2021-05-11 10:07:27" itemprop="dateModified" datetime="2021-05-11T10:07:27+08:00">2021-05-11</time>
</span>
<span id="/2021/05/10/JetpackCompose-Composer/" class="post-meta-item leancloud_visitors" data-flag-title="Jetpack Compose 核心组件 - Composer" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>Composer是Compose框架的核心组件。顾名思义,它是用来<strong>执行Compose函数</strong>并<strong>维护底层数据结构的</strong>工具</p>
<p>Compose所使用的数据结构不同于传统View系统使用的树,而是一种基于<code>连续List</code>的数据结构 - <strong>Gap Buffer</strong></p>
<h2 id="Gap-Buffer"><a href="#Gap-Buffer" class="headerlink" title="Gap Buffer"></a>Gap Buffer</h2><p>先来看看Gap Buffer的结构是什么样的,举个例子:</p>
<ol>
<li>[ ]</li>
<li>这是一种数据结构[ ]</li>
<li>这是一种[ ]数据结构</li>
<li>这是一种基于列表的[ ]数据结构</li>
<li>这是一种基于[ ]列表的数据结构</li>
<li>这是一种基于[ ]列表的数据结构</li>
<li>这是一种基于连续[ ]列表的数据结构</li>
</ol>
<p>这就是Gap Buffer的基本操作,这种数据结构被广泛用在文本编辑中。</p>
<p>其中<code>[ ]</code>代表<code>gap</code>,具有如下特点:</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2021/05/10/JetpackCompose-Composer/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2021/03/01/DynamicProxy/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2021/03/01/DynamicProxy/" class="post-title-link" itemprop="url">Java动态代理</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-03-01 16:47:48" itemprop="dateCreated datePublished" datetime="2021-03-01T16:47:48+08:00">2021-03-01</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2021-05-11 10:07:18" itemprop="dateModified" datetime="2021-05-11T10:07:18+08:00">2021-05-11</time>
</span>
<span id="/2021/03/01/DynamicProxy/" class="post-meta-item leancloud_visitors" data-flag-title="Java动态代理" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="代理模式"><a href="#代理模式" class="headerlink" title="代理模式"></a>代理模式</h1><p>说动态代理肯定就得先弄明白什么是代理模式。</p>
<p>现在思考这样一个场景:</p>
<p><strong>买一台电脑,直接去官网买是原价,去并夕夕买可以便宜500同时积分,请问你是选择官网还是并夕夕?</strong></p>
<p>在这个场景中,官网就是<code>被代理类</code>,并夕夕就是<code>代理类</code>,代理的行为是<code>卖电脑</code>,可以看出经过了并夕夕的代理同样的商品变得更便宜了。在这个买卖过程中,用户并不需要关心电脑是如何打折的,只是花了钱同时达到了目的。这就是代理模式的应用场景:</p>
<p><strong>代理模式可以在完成主要任务的同时完成一些前置或后置的工作,这个过程对用户透明,用户只需要关心主要任务</strong>。</p>
<p>代理模式在很多中场景下都发挥了很大的作用,比如<code>Windows</code>中的快捷方式就是一个代理模式的应用,通过将启动程序的操作代理给快捷方式,可以在启动时直接加载快捷方式带有的参数。</p>
<h2 id="两种代理实现方式"><a href="#两种代理实现方式" class="headerlink" title="两种代理实现方式"></a>两种代理实现方式</h2><p>代理模式一般分为<strong>静态代理</strong>和<strong>动态代理</strong>。</p>
<p>举个例子,我们现在有一个工作叫卖电脑:</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2021/03/01/DynamicProxy/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2021/02/08/Kotlin-BackingProperty/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2021/02/08/Kotlin-BackingProperty/" class="post-title-link" itemprop="url">Kotlin-幕后属性</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-02-08 16:13:50 / 修改时间:19:54:46" itemprop="dateCreated datePublished" datetime="2021-02-08T16:13:50+08:00">2021-02-08</time>
</span>
<span id="/2021/02/08/Kotlin-BackingProperty/" class="post-meta-item leancloud_visitors" data-flag-title="Kotlin-幕后属性" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Property-属性"><a href="#Property-属性" class="headerlink" title="Property(属性)"></a>Property(属性)</h1><p>在说<code>BackingProperty</code>之前要先知道什么<code>Property</code>。</p>
<p>先考虑一个问题,我们经常说的<code>Field</code>,<code>Property</code>,<code>Variable</code>到底各自指代什么?</p>
<blockquote>
<p><a target="_blank" rel="noopener" href="https://docs.oracle.com/javase/tutorial/information/glossary.html">Glossary of Terms (oracle.com)</a></p>
</blockquote>
<p>其实是可以在Oracle官网上找到答案的:</p>
<ul>
<li>Field :类的数据元素,除非特别指明,否则<code>field</code>是非静态的</li>
<li>Property : 可设置的一个对象的特点(feature)</li>
<li>Variable : 不特别与实例相关的数据元素</li>
</ul>
<p>通过上面的描述可以看出,其实根据与类实例的相关性,可以将<code>Variable</code>单独考虑。</p>
<p>其余两种则可以通过是对外提供操作来区分<code>Field(不对外提供操作)</code>和<code>Property(对外提供操作)</code></p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2021/02/08/Kotlin-BackingProperty/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/12/11/Handler/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/12/11/Handler/" class="post-title-link" itemprop="url">保姆级Handler机制解读</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-12-11 15:39:04" itemprop="dateCreated datePublished" datetime="2020-12-11T15:39:04+08:00">2020-12-11</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2020-12-15 19:36:57" itemprop="dateModified" datetime="2020-12-15T19:36:57+08:00">2020-12-15</time>
</span>
<span id="/2020/12/11/Handler/" class="post-meta-item leancloud_visitors" data-flag-title="保姆级Handler机制解读" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="什么是-Handler"><a href="#什么是-Handler" class="headerlink" title="什么是 Handler"></a>什么是 Handler</h1><p>先来看看文档中是怎么说的:</p>
<blockquote>
<p>A Handler allows you to send and process Message and Runnable objects associated with a thread’s MessageQueue. Each Handler instance is associated with a single thread and that thread’s message queue. When you create a new Handler it is bound to a Looper. It will deliver messages and runnables to that Looper’s message queue and execute them on that Looper’s thread.</p>
</blockquote>
<p>意思是说<code>Handler</code>是一个用于处理<code>Message</code>和执行<code>Runnable</code>的工具。每个<code>Thread</code>都通过<code>Looper</code>维护一个<code>MessageQueue</code>。每实例化一个<code>Handler</code>都需要绑定一个<code>Looper</code>。<code>Handler</code>主要功能就是向<code>MessageQueue</code>中发送<code>Message</code>和<code>Runnable</code>,并在<code>Message</code>被处理的时候执行其中的<code>Runnable</code>。</p>
<p>可以看到<code>Handler</code>的背后是一整套的<strong>消息流水线机制</strong>,而<code>Handler</code>只是我们利用这套机制的入口。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/12/11/Handler/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/12/10/LeetCode-25-Hard-LinkedList-reverseKGroup/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/12/10/LeetCode-25-Hard-LinkedList-reverseKGroup/" class="post-title-link" itemprop="url">LeetCode.25 Hard k个一组翻转链表</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-12-10 20:48:08 / 修改时间:21:03:40" itemprop="dateCreated datePublished" datetime="2020-12-10T20:48:08+08:00">2020-12-10</time>
</span>
<span id="/2020/12/10/LeetCode-25-Hard-LinkedList-reverseKGroup/" class="post-meta-item leancloud_visitors" data-flag-title="LeetCode.25 Hard k个一组翻转链表" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="Quistion"><a href="#Quistion" class="headerlink" title="Quistion"></a>Quistion</h1><p>给你一个链表,每 k 个节点一组进行翻转,请你返回翻转后的链表。</p>
<p>k 是一个正整数,它的值小于或等于链表的长度。</p>
<p>如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺序。</p>
<p>示例:</p>
<p>给你这个链表:1->2->3->4->5</p>
<p>当 k = 2 时,应当返回: 2->1->4->3->5</p>
<p>当 k = 3 时,应当返回: 3->2->1->4->5</p>
<p>说明:</p>
<p>你的算法只能使用常数的额外空间。<br>你不能只是单纯的改变节点内部的值,而是需要实际进行节点交换。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/12/10/LeetCode-25-Hard-LinkedList-reverseKGroup/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/12/07/ThreadPoolExecutor/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/12/07/ThreadPoolExecutor/" class="post-title-link" itemprop="url">保姆级ThreadPoolExecutor分析</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-12-07 20:42:57 / 修改时间:20:48:00" itemprop="dateCreated datePublished" datetime="2020-12-07T20:42:57+08:00">2020-12-07</time>
</span>
<span id="/2020/12/07/ThreadPoolExecutor/" class="post-meta-item leancloud_visitors" data-flag-title="保姆级ThreadPoolExecutor分析" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="池化"><a href="#池化" class="headerlink" title="池化"></a>池化</h1><p>如果一个对象需要多次使用,并且会同时存在很多个的情况下,如果每个都去重新创建会浪费非常多的性能。<br>这个时候就需要池化技术来帮助减小多次重新创建的负担。<br>池化技术的主要目的就是为了减少<code>大量</code>的创建操作导致性能损耗,通过一个<code>对象池</code>来提供复用对象。 </p>
<h1 id="为什么需要线程池"><a href="#为什么需要线程池" class="headerlink" title="为什么需要线程池"></a>为什么需要线程池</h1><p>线程池是经常使用的线程池化工具。<br>如果不使用线程池的话,每发生一个请求都需要创建一个新的线程,但如果并发请求的量非常大
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/12/07/ThreadPoolExecutor/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/12/03/ThreadLocal/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/12/03/ThreadLocal/" class="post-title-link" itemprop="url">理解ThreadLocal</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-12-03 12:44:20 / 修改时间:13:07:52" itemprop="dateCreated datePublished" datetime="2020-12-03T12:44:20+08:00">2020-12-03</time>
</span>
<span id="/2020/12/03/ThreadLocal/" class="post-meta-item leancloud_visitors" data-flag-title="理解ThreadLocal" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="ThreadLocal"><a href="#ThreadLocal" class="headerlink" title="ThreadLocal"></a>ThreadLocal</h1><p><code>ThreadLocal<T></code>可以认为是一个绑定到当前<code>Thread</code>的标签。<br>可以将一个<code>value</code>绑定到这个标签,形成一个<code>Entry</code>存储到由<code>Thread</code>维护的<code>ThreadLocalMap</code>中。 </p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/12/03/ThreadLocal/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/11/09/%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E5%92%8C%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/11/09/%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E5%92%8C%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6/" class="post-title-link" itemprop="url">内存泄漏和垃圾回收</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-11-09 11:20:19" itemprop="dateCreated datePublished" datetime="2020-11-09T11:20:19+08:00">2020-11-09</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2020-12-10 21:03:21" itemprop="dateModified" datetime="2020-12-10T21:03:21+08:00">2020-12-10</time>
</span>
<span id="/2020/11/09/%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E5%92%8C%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6/" class="post-meta-item leancloud_visitors" data-flag-title="内存泄漏和垃圾回收" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="什么是内存泄漏"><a href="#什么是内存泄漏" class="headerlink" title="什么是内存泄漏"></a>什么是内存泄漏</h1><p>内存泄漏顾名思义,就是本应该被回收的无用资源并没有被正确的回收而导致内存的浪费。想搞清楚到底是什么原因导致这些资源没有被回收就需要对JVM的内存模型,以及JVM的垃圾回收机制有一定的了解。</p>
<h1 id="JVM内存模型"><a href="#JVM内存模型" class="headerlink" title="JVM内存模型"></a>JVM内存模型</h1><p>在JVM中主要分为<code>类加载器</code>,<code>内存区域(运行时数据区)</code>,<code>执行引擎</code>,<code>本地库接口</code>和<code>本地方法库</code>。我们探究JVM的内存模型以及内存泄漏,这一部分的原理基本都在<code>内存区域中</code>。<br>我们先来看一下这个<code>运行时数据区</code>长什么样:</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/11/09/%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E5%92%8C%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/11/01/Android-Activity%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/11/01/Android-Activity%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/" class="post-title-link" itemprop="url">Activity生命周期</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-11-01 18:57:22" itemprop="dateCreated datePublished" datetime="2020-11-01T18:57:22+08:00">2020-11-01</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2020-11-10 10:22:37" itemprop="dateModified" datetime="2020-11-10T10:22:37+08:00">2020-11-10</time>
</span>
<span id="/2020/11/01/Android-Activity%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/" class="post-meta-item leancloud_visitors" data-flag-title="Activity生命周期" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>作为Android四大组件中最为基础的组件,Ativity承担着应用和用户交互的基本任务。</p>
<p>Activity是应用与用户进行交互的单一焦点,基本所有Activity都与用户进行交互。所以Activity负责创建一个<code>Window</code>,可以通过<code>setContentView</code>方法加载UI。<br>Activity经常以<code>全屏窗口</code>向用户展示用户界面,或者可以通过在<code>theme</code>中设置<code>windowIsFloating</code>flag使之变为一个<code>悬浮窗口</code>,还可以启用<code>多窗口</code>模式,或将窗口<code>嵌入其他窗口</code>中。 </p>
<p>Activity在系统中以<code>activity stack</code>的形式进行管理。当一个新的activity启动的时候,一般情况下会被放入当前<code>activity stack</code>的栈顶,成为<code>running activity</code>。一般情况下前一个activity依旧会存于与栈中,但是只要栈顶activity还存在就不会回到前台。<br>注意在屏幕上看到的Activity可能属于不同的<code>activity stack</code>。 </p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2020/11/01/Android-Activity%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://shiro-umi.github.io/2020/10/18/Java_%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B-%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A8%E7%A4%BA/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Shiro-umi">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="ShiroUmi">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a href="/2020/10/18/Java_%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B-%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A8%E7%A4%BA/" class="post-title-link" itemprop="url">Java_基本数据类型&二进制表示</a>
</h1>
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-10-18 08:47:35" itemprop="dateCreated datePublished" datetime="2020-10-18T08:47:35+08:00">2020-10-18</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2020-11-03 20:05:44" itemprop="dateModified" datetime="2020-11-03T20:05:44+08:00">2020-11-03</time>
</span>
<span id="/2020/10/18/Java_%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B-%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A8%E7%A4%BA/" class="post-meta-item leancloud_visitors" data-flag-title="Java_基本数据类型&二进制表示" title="阅读次数">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读次数:</span>
<span class="leancloud-visitors-count"></span>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="bit-比特-amp-byte-字节"><a href="#bit-比特-amp-byte-字节" class="headerlink" title="bit(比特)&byte(字节)"></a>bit(比特)&byte(字节)</h2><p><code>bit</code>叫做<code>位</code>或者<code>比特</code>,在计算机中数据都是以<code>0</code>和<code>1</code>存储的,一个<code>bit</code>就对应一位数字<br><code>byte</code>叫做<code>字节</code>,是比<code>bit</code>更高位的计量单位</p>
<ul>
<li><code>1byte = 8bits</code></li>
</ul>
<h2 id="java中的基本数据类型"><a href="#java中的基本数据类型" class="headerlink" title="java中的基本数据类型"></a>java中的基本数据类型</h2><table>
<thead>
<tr>
<th align="left">catagory</th>
<th align="left">bytes</th>
<th align="left">bits</th>
<th align="left">范围($2^n$)</th>
</tr>
</thead>
<tbody><tr>
<td align="left">boolean</td>
<td align="left">1</td>
<td align="left">8</td>
<td align="left">$(-2)^7$ ~ $2^7-1$</td>
</tr>
<tr>
<td align="left">char</td>
<td align="left">2</td>
<td align="left">16</td>
<td align="left">$(-2)^{15}$ ~ $2^{15}-1$</td>
</tr>
<tr>
<td align="left">—-</td>
<td align="left">—-</td>
<td align="left">—-</td>
<td align="left">—-</td>
</tr>
<tr>
<td align="left">byte</td>
<td align="left">1</td>
<td align="left">8</td>
<td align="left">$(-2)^7$ ~ $2^7-1$</td>
</tr>
<tr>
<td align="left">short</td>
<td align="left">2</td>
<td align="left">16</td>
<td align="left">$(-2)^{15}$ ~ $2^{15}-1$</td>
</tr>