Skip to content

Commit bc2d69d

Browse files
committed
Merge branch 'master' of github.com:LittleFriendsGroup/AndroidSdkSourceAnalysis
2 parents c4a802c + 0b86a11 commit bc2d69d

File tree

7 files changed

+718
-214
lines changed

7 files changed

+718
-214
lines changed

README.md

Lines changed: 181 additions & 202 deletions
Large diffs are not rendered by default.

article/LruCache源码解析.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ this.bitmapCache = new LruCache<String, Bitmap>(CACHE_SIZE) {
4545
[LruCache 效果展示](https://github.com/CaMnter/AndroidLife/blob/master/article/LruCache%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90_%E6%95%88%E6%9E%9C%E5%B1%95%E7%A4%BA.md)
4646

4747

48-
## 4. 源码分析
48+
## 4. 源码分析
4949

5050
### 4.1 LruCache 原理概要解析
5151

@@ -61,7 +61,7 @@ LruCache 就是 **利用 LinkedHashMap 的一个特性( accessOrder=true 基
6161

6262
- 4.`LinkedHashMap` 是双向循环链表,然后每次 `LruCache.get` -> `LinkedHashMap.get` 的数据就被放到最末尾了。
6363

64-
- 5.在 `put``trimToSize` 的方法执行下,如果发成数据量移除了,会优先移除掉最前面的数据(因为最新访问的数据在尾部)。
64+
- 5.在 `put``trimToSize` 的方法执行下,如果发生数据量移除,会优先移除掉最前面的数据(因为最新访问的数据在尾部)。
6565

6666
**具体解析在:** *4.2**4.3**4.4**4.5*
6767

@@ -74,7 +74,7 @@ LruCache 就是 **利用 LinkedHashMap 的一个特性( accessOrder=true 基
7474
public LruCache(int maxSize) {
7575

7676
...
77-
77+
7878
this.maxSize = maxSize;
7979
/*
8080
* 初始化LinkedHashMap
@@ -99,9 +99,9 @@ public LruCache(int maxSize) {
9999
* 如果如果没有缓存的值,则返回 null。
100100
*/
101101
public final V get(K key) {
102-
102+
103103
...
104-
104+
105105
V mapValue;
106106
synchronized (this) {
107107
// 关键点:LinkedHashMap每次get都会基于访问顺序来重整数据顺序
@@ -315,7 +315,7 @@ public void trimToSize(int maxSize) {
315315

316316
---
317317

318-
最后看看:
318+
最后看看:
319319

320320
### 4.8 覆写 entryRemoved 的作用
321321

@@ -356,7 +356,7 @@ protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {
356356

357357
## 5. 开源项目中的使用
358358

359-
[square/picasso](https://github.com/square/picasso)
359+
[square/picasso](https://github.com/square/picasso)
360360

361361

362362
## 6. 总结
@@ -382,8 +382,3 @@ LruCache重要的几点:
382382

383383

384384
[LruCache 注释源码](https://github.com/CaMnter/AndroidLife/blob/master/app/src/main/java/com/camnter/newlife/utils/cache/LruCache.java)
385-
386-
387-
388-
389-

0 commit comments

Comments
 (0)