当前位置: 首页 > news >正文

Android提供的LruCache类简介(1)

  1. If your cached values hold resources that need to be explicitly released,

  2. * override {@link #entryRemoved}.

  3. * 如果你cache的某个值需要明确释放,重写entryRemoved()

  4. If a cache miss should be computed on demand for the corresponding keys,

  5. * override {@link #create}. This simplifies the calling code, allowing it to

  6. * assume a value will always be returned, even when there’s a cache miss.

  7. * 如果key相对应的item丢掉啦,重写create().这简化了调用代码,即使丢失了也总会返回。

  8. By default, the cache size is measured in the number of entries. Override

  9. * {@link #sizeOf} to size the cache in different units. For example, this cache

  10. * is limited to 4MiB of bitmaps: 默认cache大小是测量的item的数量,重写sizeof计算不同item的

  11. *  大小。

  12.    {@code

  13. *   int cacheSize = 4 * 1024 * 1024; // 4MiB

  14. *   LruCache<String, Bitmap> bitmapCache = new LruCache<String, Bitmap>(cacheSize) {

  15. *       protected int sizeOf(String key, Bitmap value) {

  16. *           return value.getByteCount();

  17. *       }

  18. *   }}

  19. *

  20. This class is thread-safe. Perform multiple cache operations atomically by

  21. * synchronizing on the cache: 

       {@code

  22. *   synchronized (cache) {

  23. *     if (cache.get(key) == null) {

  24. *         cache.put(key, value);

  25. *     }

  26. *   }}

  27. *

  28. This class does not allow null to be used as a key or value. A return

  29. * value of null from {@link #get}, {@link #put} or {@link #remove} is

  30. * unambiguous: the key was not in the cache.

  31. * 不允许key或者value为null

  32. *  当get(),put(),remove()返回值为null时,key相应的项不在cache中

  33. */

  34. public class LruCache<K, V> {

  35. private final LinkedHashMap<K, V> map;

  36. /** Size of this cache in units. Not necessarily the number of elements. */

  37. private int size; //已经存储的大小

  38. private int maxSize; //规定的最大存储空间

  39. private int putCount;  //put的次数

  40. private int createCount;  //create的次数

  41. private int evictionCount;  //回收的次数

  42. private int hitCount;  //命中的次数

  43. private int missCount;  //丢失的次数

  44. /**

  45. * @param maxSize for caches that do not override {@link #sizeOf}, this is

  46. *     the maximum number of entries in the cache. For all other caches,

  47. *     this is the maximum sum of the sizes of the entries in this cache.

  48. */

  49. public LruCache(int maxSize) {

  50. if (maxSize <= 0) {

  51. throw new IllegalArgumentException(“maxSize <= 0”);

  52. }

  53. this.maxSize = maxSize;

  54. this.map = new LinkedHashMap<K, V>(0, 0.75f, true);

  55. }

  56. /**

  57. * Returns the value for {@code key} if it exists in the cache or can be

  58. * created by {@code #create}. If a value was returned, it is moved to the

  59. * head of the queue. This returns null if a value is not cached and cannot

  60. * be created. 通过key返回相应的item,或者创建返回相应的item。相应的item会移动到队列的头部,

  61. * 如果item的value没有被cache或者不能被创建,则返回null。

  62. */

  63. public final V get(K key) {

  64. if (key == null) {

  65. throw new NullPointerException(“key == null”);

  66. }

  67. V mapValue;

  68. synchronized (this) {

  69. mapValue = map.get(key);

  70. if (mapValue != null) {

  71. hitCount++;  //命中

  72. return mapValue;

  73. }

  74. missCount++;  //丢失

  75. }

  76. /*

  77. * Attempt to create a value. This may take a long time, and the map

  78. * may be different when create() returns. If a conflicting value was

  79. * added to the map while create() was working, we leave that value in

  80. * the map and release the created value.

  81. * 如果丢失了就试图创建一个item

  82. */

  83. V createdValue = create(key);

  84. if (createdValue == null) {

  85. return null;

  86. }

  87. synchronized (this) {

  88. createCount++;//创建++

  89. mapValue = map.put(key, createdValue);

  90. if (mapValue != null) {

  91. // There was a conflict so undo that last put

  92. //如果前面存在oldValue,那么撤销put()

  93. map.put(key, mapValue);

  94. } else {

  95. size += safeSizeOf(key, createdValue);

  96. }

  97. }

  98. if (mapValue != null) {

  99. entryRemoved(false, key, createdValue, mapValue);

  100. return mapValue;

  101. } else {

  102. trimToSize(maxSize);

  103. return createdValue;

  104. }

  105. }

  106. /**

  107. * Caches {@code value} for {@code key}. The value is moved to the head of

  108. * the queue.

  109. *

  110. * @return the previous value mapped by {@code key}.

  111. */

  112. public final V put(K key, V value) {

  113. if (key == null || value == null) {

  114. throw new NullPointerException(“key == null || value == null”);

  115. }

  116. V previous;

  117. synchronized (this) {

  118. putCount++;

  119. size += safeSizeOf(key, value);

  120. previous = map.put(key, value);

  121. if (previous != null) {  //返回的先前的value值

  122. size -= safeSizeOf(key, previous);

  123. }

  124. }

  125. if (previous != null) {

  126. entryRemoved(false, key, previous, value);

  127. }

  128. trimToSize(maxSize);

  129. return previous;

  130. }

  131. /**

  132. * @param maxSize the maximum size of the cache before returning. May be -1

  133. *     to evict even 0-sized elements.

  134. *  清空cache空间

  135. */

  136. private void trimToSize(int maxSize) {

  137. while (true) {

  138. K key;

  139. V value;

  140. synchronized (this) {

  141. if (size < 0 || (map.isEmpty() && size != 0)) {

  142. throw new IllegalStateException(getClass().getName()

  143. + “.sizeOf() is reporting inconsistent results!”);

  144. }

  145. if (size <= maxSize) {

  146. break;

  147. }

  148. Map.Entry<K, V> toEvict = map.eldest();

  149. if (toEvict == null) {

  150. break;

  151. }

  152. key = toEvict.getKey();

  153. value = toEvict.getValue();

  154. map.remove(key);

  155. size -= safeSizeOf(key, value);

  156. evictionCount++;

  157. }

  158. entryRemoved(true, key, value, null);

  159. }

  160. }

  161. /**

  162. * Removes the entry for {@code key} if it exists.

  163. * 删除key相应的cache项,返回相应的value

  164. * @return the previous value mapped by {@code key}.

  165. */

  166. public final V remove(K key) {

  167. if (key == null) {

  168. throw new NullPointerException(“key == null”);

  169. }

  170. V previous;

  171. synchronized (this) {

  172. previous = map.remove(key);

  173. if (previous != null) {

  174. size -= safeSizeOf(key, previous);

  175. }

  176. }

  177. if (previous != null) {

  178. entryRemoved(false, key, previous, null);

  179. }

  180. return previous;

  181. }

  182. /**

  183. * Called for entries that have been evicted or removed. This method is

  184. * invoked when a value is evicted to make space, removed by a call to

  185. * {@link #remove}, or replaced by a call to {@link #put}. The default

  186. * implementation does nothing.

  187. * 当item被回收或者删掉时调用。改方法当value被回收释放存储空间时被remove调用,

  188. * 或者替换item值时put调用,默认
    实现什么都没做。

  189. The method is called without synchronization: other threads may

  190. * access the cache while this method is executing.

  191. *

  192. * @param evicted true if the entry is being removed to make space, false

  193. *     if the removal was caused by a {@link #put} or {@link #remove}.

  194. * true—为释放空间被删除;false—put或remove导致

  195. * @param newValue the new value for {@code key}, if it exists. If non-null,

  196. *     this removal was caused by a {@link #put}. Otherwise it was caused by

  197. *     an eviction or a {@link #remove}.

  198. */

  199. protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}

  200. /**

  201. * Called after a cache miss to compute a value for the corresponding key.

  202. * Returns the computed value or null if no value can be computed. The

  203. * default implementation returns null.

  204. * 当某Item丢失时会调用到,返回计算的相应的value或者null

  205. The method is called without synchronization: other threads may

  206. * access the cache while this method is executing.

  207. *

  208. If a value for {@code key} exists in the cache when this method

  209. * returns, the created value will be released with {@link #entryRemoved}

  210. * and discarded. This can occur when multiple threads request the same key

  211. * at the same time (causing multiple values to be created), or when one

  212. * thread calls {@link #put} while another is creating a value for the same

  213. * key.

  214. */

  215. protected V create(K key) {

  216. return null;

  217. }

  218. private int safeSizeOf(K key, V value) {

  219. int result = sizeOf(key, value);

  220. if (result < 0) {

  221. throw new IllegalStateException("Negative size: " + key + “=” + value);

  222. }

  223. return result;

  224. }

  225. /**

  226. * Returns the size of the entry for {@code key} and {@code value} in

  227. * user-defined units.  The default implementation returns 1 so that size

  228. * is the number of entries and max size is the maximum number of entries.

  229. * 返回用户定义的item的大小,默认返回1代表item的数量,最大size就是最大item值

  230. An entry’s size must not change while it is in the cache.

  231. */

  232. protected int sizeOf(K key, V value) {

  233. return 1;

  234. }

  235. /**

  236. * Clear the cache, calling {@link #entryRemoved} on each removed entry.

最后

小编这些年深知大多数初中级Android工程师,想要提升自己,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助

因此我收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人

都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

资料⬅专栏获取
0.      */

  1. protected int sizeOf(K key, V value) {

  2. return 1;

  3. }

  4. /**

  5. * Clear the cache, calling {@link #entryRemoved} on each removed entry.

最后

小编这些年深知大多数初中级Android工程师,想要提升自己,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助

因此我收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。

[外链图片转存中…(img-7R2o989d-1718991877996)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人

都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

资料⬅专栏获取

相关文章:

Android提供的LruCache类简介(1)

* If your cached values hold resources that need to be explicitly released, * override {link #entryRemoved}. * 如果你cache的某个值需要明确释放&#xff0c;重写entryRemoved() * If a cache miss should be computed on demand for the corresponding keys, * ov…...

【分布式系列】分布式锁timeout了怎么办?

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…...

System.getProperty()方法总结

System.getProperty()方法总结 大家好&#xff0c;我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编&#xff0c;也是冬天不穿秋裤&#xff0c;天冷也要风度的程序猿&#xff01;System.getProperty()方法是Java中用于获取系统属性的方法之一。它允许我们访问J…...

大型语言模型在AMD GPU上的推理优化

Large language model inference optimizations on AMD GPUs — ROCm Blogs 大型语言模型&#xff08;LLMs&#xff09;已经改变了自然语言处理和理解&#xff0c;促进了在多个领域中的众多人工智能应用。LLMs在包括AI助手、聊天机器人、编程、游戏、学习、搜索和推荐系统在内的…...

Apple - Core Foundation Design Concepts

本文翻译整理自&#xff1a;Core Foundation Design Concepts&#xff08;更新日期&#xff1a;2013-12-16 https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFDesignConcepts/CFDesignConcepts.html#//apple_ref/doc/uid/10000122i 文章…...

lua中的lfs库介绍

lua中的lfs库介绍 说明常用函数解析lfs.attributeslfs.chdirlfs.currentdirlfs.dirlfs.mkdirlfs.rmdirlfs.locklfs.touchlfs.linklfs.setmodelfs.symlinkattributes 说明 lfs是lua中的一个文件系统库&#xff0c;提供了更多高级的文件和目录操作功能&#xff0c;使得lua可以更方…...

PyCharm 快捷键积累

1、快速格式化&#xff1a;Ctrl Alt L Ctrl Alt L 快捷键在 PyCharm 中是用于格式化代码的&#xff0c;它不仅仅适用于 HTML 代码&#xff0c;而是适用于多种编程和标记语言。...

C++进阶之AVL树

个人主页&#xff1a;点我进入主页 专栏分类&#xff1a;C语言初阶 C语言进阶 数据结构初阶 Linux C初阶 C进阶​ ​​​​算法 欢迎大家点赞&#xff0c;评论&#xff0c;收藏。 一起努力&#xff0c;一起奔赴大厂 目录 一.前言 二.插入 三.旋转 3.1右旋 …...

sizeof 和 strlen 比较

sizeof 和 strlen 在 C 语言中都是用于获取某种“大小”的&#xff0c;但它们之间有着显著的区别。 sizeof sizeof 是一个运算符&#xff0c;用于计算数据类型或对象在内存中的大小&#xff08;以字节为单位&#xff09;。它可以在编译时确定结果&#xff0c;因为它计算的是类…...

音视频开发—FFmpeg 打开摄像头进行RTMP推流

实验平台&#xff1a;Ubuntu20.04 摄像头&#xff1a;普通USB摄像头&#xff0c;输出格式为YUV422 1.配置RTMP服务器推流平台 使用Nginx 配置1935端口即可&#xff0c;贴上教程地址 ubuntu20.04搭建Nginxrtmp服务器) 2.配置FFmpeg开发环境 过程较为简单&#xff0c;这里不…...

D触发器(D Flip-Flop)与D锁存器(D Latch)

1 基础概念 我们先来简单回顾一下D触发器&#xff08;D flip-flop&#xff09;和D锁存器&#xff08;D latch&#xff09;的概念&#xff0c;以及它们在数字电路中的作用。 1.1 D触发器&#xff08;D Flip-Flop&#xff09; D触发器是一种数字存储器件&#xff0c;它在时钟信号…...

JDK19特性

JDK19特性 一、JAVA19概述 JDK 19 2022 年 9 月 20 日正式发布以供生产使用,非长期支持版本。不过,JDK 19 中有一些比较重要的新特性值得关注。 JDK 19 只有 7 个新特性: JEP 405: Record Patterns(记录模式)[1] (预览)JEP 422: Linux/RISC-V Port[2]JEP 424: Foreign …...

sql语句中常用的函数有那些

1、字符串函数 CONCAT(string1, string2, ...): 连接两个或多个字符串。 UPPER(string): 将字符串转换为大写。 LOWER(string): 将字符串转换为小写。 TRIM(string): 去除字符串两端的空格。 LENGTH(string): 返回字符串的长度。 SUBSTRING(string, start, length): 从字符串中…...

odoo17 小变更3 Warning、 “attrs “和 “states “不再用

odoo17 小变更 1、Warning from odoo.exceptions import ValidationError,Warning ImportError: cannot import name Warning from odoo.exceptions (D:\od172406\odoo\exceptions.py) 2、自 17.0 版起&#xff0c;不再使用 "attrs "和 "states "属性。 …...

Unity3d 游戏暂停(timeScale=0)引起的deltaTime关联的系列问题解决

问题描述 游戏暂停的功能是通过设置timeScale0实现的&#xff0c;不过在暂停游戏的时候&#xff0c;需要对角色进行预览和设置&#xff0c;为了实现这个功能&#xff0c;是通过鼠标控制相机的操作&#xff0c;为了使相机的操作丝滑&#xff0c;获取鼠标操作系数乘以Time.delta…...

服务端代码编写中MySql大小写在Java中报错问题解决

报错信息&#xff1a; 原因&#xff1a;MySql和Java变量大小写产生的冲突。 经过查阅各个博客等&#xff0c;得出浅显结论&#xff08;不一定对&#xff09;&#xff1a;MySql大小写不敏感&#xff0c;Java大小写敏感&#xff0c;当Javabean转为MySql数据库表时&#xff0c;Ja…...

CRMEB 多店商品详情页装修说明

一、功能介绍 商家可调整商品详情各板块样式&#xff0c;可根据不同的需求开启或关闭单独的板块 二、操作流程 装修 > 商品详情 三、功能说明 1、商品信息 可控制商品详情页面商品信息的显示与隐藏 2、会员信息&#xff0c;排行榜 控制商品详情页面会员信息及排行榜的…...

Redis-使用 jedis 操作数据

文章目录 1、Jedis简介2、环境准备3、创建maven普通项目,导入如下依赖4、测试JAVA程序和Redis之间的通信 1、Jedis简介 "Jedis" 通常是作为 "Java Redis" 的缩写或简称来理解的。Java Embedded Data Structures Interface 表示 Java嵌入式数据结构接口 2、…...

简说PIP换源

概述 PIP&#xff08;Python Package Installer&#xff09;是 Python 的包管理工具&#xff0c;用于安装和管理 Python 包。默认情况下&#xff0c;PIP 从 Python 官方的包仓库&#xff08;即 PyPI&#xff09;下载和安装包。然而&#xff0c;由于网络原因&#xff0c;访问官…...

django学习入门系列之第三点《CSS基础样式介绍2》

文章目录 文字对齐方式外边距内边距往期回顾 文字对齐方式 水平对齐方式 text-align: center;垂直对齐方式 /* 注意&#xff0c;这个只能是一行来居中 */ line-height:/*长度*/ ;样例 <!DOCTYPE html> <html lang"en"> <head><meta charset…...

分布式光纤测温DTS在工程现场中稳定性与可靠性如何?

20年前&#xff0c;分布式光纤测温(Distributed Temperature Sensing&#xff0c;DTS)技术的发展尚不成熟&#xff0c;设备成本高昂&#xff0c;其稳定性与可靠性也存在一定问题。然而&#xff0c;经过二十多年的不断发展与创新&#xff0c;DTS技术在工程现场应用中取得了显著进…...

PHP多线程模块parallel的编译安装和多线程编程演示

从PHP7开始&#xff0c;多线程编原有的pthreads已经不在维护&#xff0c;而是使用parallel替代。 由于是新的模块&#xff0c;样例代码很少&#xff0c;这里总结一个简单的代码和详细的备注供大家参考。 编译和安装 parallel需要启用ZTS&#xff08;Zend Thread Safety&…...

记录grid布局属性

grid布局 分为容器和项目元素 容器属性 #container{display:grid;grid-template-columns:100px 100px 100px;/* 1fr 表示比例为占1份 */grid-template-columns:1fr 100px 1fr;/*100px为1列,自动填充,容器宽度不足则换行*/grid-template-columns:repeat(auto-fill,100px);/* …...

12.爬虫---PyMysql安装与使用

12.PyMysql安装与使用 1.安装 PyMySQL2.使用PyMySQL2.1创建数据表2.2连接数据库2.3增加数据2.4修改数据2.5查询数据2.6删除数据2.7关闭连接 3.总结 MySQL 安装可以看这篇文章MySql 安装与使用&#xff08;非常详细&#xff09; 1.安装 PyMySQL PyMySQL是Python中用于连接MySQL…...

VS2022遇到的两个问题

问题一&#xff1a;找不到定义的头文件 别的博主说是&#xff1a;在属性页里面进行改写&#xff0c;改成是&#xff0c;我试过之后并不行&#xff1b; 解决思路&#xff1a;但其实在右边视图里面找到你自己定义的头文件加到你运行文件中就行&#xff1b;因为程序就只有一个入口…...

【Android14 ShellTransitions】(六)SyncGroup完成

这一节的内容在WMCore中&#xff0c;回想我们的场景&#xff0c;是在Launcher启动某一个App&#xff0c;那么参与动画的就是该App对应Task&#xff08;OPEN&#xff09;&#xff0c;以及Launcher App对应的Task&#xff08;TO_BACK&#xff09;。在确定了动画的参与者后&#x…...

技术管理转型之战:决策之道-管理中的智慧与策略

文章目录 引言一、决策的重要性二、常见的决策方式1. 理性决策&#xff08;Rational Decision Making&#xff09;2. 有限理性&#xff08;Bounded Rationality&#xff09;3. 直觉决策&#xff08;Intuitive Decision Making&#xff09;4. 循证管理&#xff08;Evidence-Base…...

Shell脚本:条件语句(if、case)

目录 硬编码 硬编码的缺点 条件判断 $? 命令行语句 判断指定目录是否存在 判断指定文件是否存在 判断指定对象是否存在 表达式形式语句 判断对象是否存在 判断对象是否有权限 与、或、非 运算 与运算 或运算 非运算 比较大小 判断磁盘利用率实验步骤 字符串…...

在Linux上为Windows目标配置Qt交叉编译

问题描述 我想使用Linux x86_64主机为Windows x86_64目标交叉编译Qt库&#xff08;最终也包括我的应用程序&#xff09;。我觉得自己已经接近成功了&#xff0c;但可能对整个过程有一些基本的误解。 我从在我的Fedora机器上安装所有mingw包开始&#xff0c;并修改了win32-g的…...

Introduction to linear optimization 第 2 章课后题答案 11-15

线性规划导论 Introduction to linear optimization (Dimitris Bertsimas and John N. Tsitsiklis, Athena Scientific, 1997)&#xff0c; 这本书的课后题答案我整理成了一个 Jupyter book&#xff0c;发布在网址&#xff1a; https://robinchen121.github.io/manual-introdu…...

Java——包

一、包 1、简要介绍 在Java编程语言中&#xff0c;包&#xff08;Package&#xff09; 是一种用来组织和管理类&#xff08;Class&#xff09;和接口&#xff08;Interface&#xff09;的机制。包为开发者提供了一种逻辑分组的方式&#xff0c;使代码更加模块化、结构化和易于…...

Pipeline知识小记

在scikit-learn&#xff08;通常缩写为sklearn&#xff09;中&#xff0c;Pipeline是一个非常重要的工具&#xff0c;它允许你将多个数据转换步骤&#xff08;如特征选择、缩放等&#xff09;和估计器&#xff08;如分类器、回归器等&#xff09;组合成一个单一的估计器对象。这…...

postman国内外竞争者及使用详解分析

一、postman简介 Postman 是一款广泛使用的 API 开发和测试工具&#xff0c;适用于开发人员和测试人员。它提供了一个直观的界面&#xff0c;用于发送 HTTP 请求、查看响应、创建和管理 API 测试用例&#xff0c;以及自动化 API 测试工作流程。以下是 Postman 的主要功能和特点…...

人工智能对决:ChatGLM与ChatGPT,探索发展历程

图: a robot is writing code on a horse, By 禅与计算机程序设计艺术 目录 ChatGLM:...

探索Python元类的奥秘及其应用场景

探索Python元类的奥秘及其应用场景 一、引言 在Python中&#xff0c;元类&#xff08;Metaclasses&#xff09;是一个相对高级且容易被忽视的主题。然而&#xff0c;对于深入理解Python的面向对象编程模型以及进行高级框架和库的设计来说&#xff0c;元类是一个不可或缺的工具…...

C语言基础关键字的含义和使用方法

​关键字在C语言中扮演着非常重要的角色&#xff0c;它们定义了语言的基本构造和语法规则&#xff0c;通过使用关键字&#xff0c;开发者可以创建变量、定义数据类型、控制程序流程&#xff08;如循环和条件判断&#xff09;、声明函数等。由于这些字是保留的&#xff0c;所以编…...

【Golang - 90天从新手到大师】Day09 - string

系列文章合集 Golang - 90天从新手到大师 String 一个字符串是一个不可改变的字节序列。字符串可以包含任意的数据&#xff0c;但是通常是用来包含人类可读的文本。 len()返回字符串字节数目&#xff08;不是rune数&#xff09;。 通过索引可以访问某个字节值&#xff0c;0…...

网络安全与区块链技术:信任与安全的融合

# 网络安全与区块链技术&#xff1a;信任与安全的融合 在网络空间&#xff0c;信任是一种宝贵而稀缺的资源。区块链技术以其独特的分布式账本、加密算法和共识机制&#xff0c;为构建网络安全提供了新的解决方案。本文将探讨网络安全与区块链技术如何融合&#xff0c;以增强信…...

MySQL之复制(九)

复制 复制管理和维护 确定主备是否一致 在理想情况下&#xff0c;备库和主库的数据应该是完全一样的。但事实上备库可能发生错误并导致数据不一致。即使没有明显的错误&#xff0c;备库同样可能因为MySQL自身的特性导致数据不一致&#xff0c;例如MySQL的Bug、网络中断、服务…...

【面试干货】 Java 中的 HashSet 底层实现

【面试干货】 Java 中的 HashSet 底层实现 1、HashSet 的底层实现2、 HashSet 的特点3、 总结 &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; HashSet 是 Java 集合框架中的一个重要成员&#xff0c;它提供了不存储重复元素的集合。但是&am…...

爬虫经典案例之爬取豆瓣电影Top250(方法二)

在上一篇文章的基础上&#xff0c;改进了代码质量&#xff0c;增加了多个正则表达式匹配&#xff0c;但同事也增加了程序执行的耗时。 from bs4 import BeautifulSoup import requests import time import re from random import randint import pandas as pdurl_list [https…...

如何优化React应用的性能?

优化React应用的性能是一个多方面的过程&#xff0c;涉及到代码的编写、组件的设计、资源的管理等多个层面。以下是一些常见的性能优化策略&#xff1a; 避免不必要的渲染: 使用React.memo、useMemo和useCallback来避免组件或其子组件不必要的重新渲染。 代码分割: 使用React.…...

css文字镂空加描边

css文字镂空加描边 <!DOCTYPE html> <html><head><meta charset"utf-8"><title>文字镂空</title><style>/* 公用样式 */html,body{width: 100%;height: 100%;position: relative;}/* html{overflow-y: scroll;} */*{margi…...

python数据分析与可视化

Python 在数据分析和可视化方面有着广泛的应用,并且拥有众多强大的库和工具来支持这些任务。以下是一些常用的 Python 库和它们的主要用途: 数据分析 Pandas: Pandas 是 Python 中用于数据处理和分析的主要库。 它提供了数据框(DataFrame)和序列(Series)两种数据结构…...

webkit 的介绍

WebKit 是一个开源的网页浏览器引擎&#xff0c;它是 Safari 浏览器和许多其他应用程序的基础。WebKit 最初由苹果公司开发&#xff0c;并在2005年作为开源项目发布。WebKit 的核心组件包括 WebCore 和 JavaScriptCore。以下是 WebKit 的详细介绍&#xff1a; ### WebKit 的主…...

make与makefile

目录 一、make的默认目标文件与自动推导 二、不能连续make的原因 执行原理 touch .PHONY伪目标 make指令不回显 makefile多文件管理 简写依赖方法 三、回车与换行 四、缓冲区 一、make的默认目标文件与自动推导 假设这是一个makefile文件&#xff0c;make的时候默认生…...

深度神经网络一

文章目录 深度神经网络 (DNN)1. 概述2. 基本概念3. 网络结构 深度神经网络的层次结构详细讲解1. 输入层&#xff08;Input Layer&#xff09;2. 隐藏层&#xff08;Hidden Layers&#xff09;3. 输出层&#xff08;Output Layer&#xff09;整体流程深度神经网络的优点深度神经…...

Pnpm:包管理的新星,如何颠覆 Npm 和 Yarn

在探索现代 JavaScript 生态系统时&#xff0c;我们常常会遇到新兴技术的快速迭代和改进。其中&#xff0c;包管理工具的发展尤为重要&#xff0c;因为它们直接影响开发效率和项目性能。最近&#xff0c;pnpm 作为一种新的包管理工具引起了广泛关注。它不仅挑战了传统工具如 np…...

汽车IVI中控开发入门及进阶(三十二):i.MX linux开发之Yocto

前言: 对于NXP的i.mx,如果基于linux开发,需要熟悉以下文档: IMX_YOCTO_PROJECT_USERS_GUIDE.pdf IMX_LINUX_USERS_GUIDE.pdf IMX_GRAPHICS_USERS_GUIDE.pdf 如果基于android开发,需要熟悉一下文档: Android_Auto_Quick_Start_Guide.pdf ANDROID_USERS_GUIDE.pdf …...

tessy 编译报错:单元测试时,普通桩函数内容相关异常场景

目录 1&#xff0c;失败现象 2&#xff0c;原因分析 1&#xff0c;失败现象 1&#xff0c;在 step 桩函数正常的情况下报错。 2&#xff0c;测试代码执行的数据流 和 step 桩函数内容不一致。 2&#xff0c;原因分析 桩函数分为 test object, test case, test step 三种类别。…...