HashMap源码注解 之 常量定义(一)
来源:互联网 发布:淘宝dota2 编辑:程序博客网 时间:2024/05/20 08:43
注意 ,本文基于JDK 1.8
1.默认容量
/** * The default initial capacity - MUST be a power of two. */static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16
默认初始化的容量为16,必须是2的幂。
2.最大容量
/** * The maximum capacity, used if a higher value is implicitly specified * by either of the constructors with arguments. * MUST be a power of two <= 1<<30. */ static final int MAXIMUM_CAPACITY = 1 << 30;
最大容量是2^30
3.装载因子
/** * The load factor used when none specified in constructor. */ static final float DEFAULT_LOAD_FACTOR = 0.75f;
默认的装载因子是0.75
4.由链表转换成树的阈值TREEIFY_THRESHOLD
/** * The bin count threshold for using a tree rather than list for a * bin. Bins are converted to trees when adding an element to a * bin with at least this many nodes. The value must be greater * than 2 and should be at least 8 to mesh with assumptions in * tree removal about conversion back to plain bins upon * shrinkage. */ static final int TREEIFY_THRESHOLD = 8;
一个桶中bin(箱子)的存储方式由链表转换成树的阈值。即当桶中bin的数量超过TREEIFY_THRESHOLD时使用树来代替链表。默认值是8
5.由树转换成链表的阈值UNTREEIFY_THRESHOLD
/** * The bin count threshold for untreeifying a (split) bin during a * resize operation. Should be less than TREEIFY_THRESHOLD, and at * most 6 to mesh with shrinkage detection under removal. */ static final int UNTREEIFY_THRESHOLD = 6;
当执行resize操作时,当桶中bin的数量少于UNTREEIFY_THRESHOLD时使用链表来代替树。默认值是6
6.MIN_TREEIFY_CAPACITY
/** * The smallest table capacity for which bins may be treeified. * (Otherwise the table is resized if too many nodes in a bin.) * Should be at least 4 * TREEIFY_THRESHOLD to avoid conflicts * between resizing and treeification thresholds. */ static final int MIN_TREEIFY_CAPACITY = 64;
当桶中的bin被树化时最小的hash表容量。(如果没有达到这个阈值,即hash表容量小于MIN_TREEIFY_CAPACITY,当桶中bin的数量太多时会执行resize扩容操作)这个MIN_TREEIFY_CAPACITY的值至少是TREEIFY_THRESHOLD的4倍。
0 0
- HashMap源码注解 之 常量定义(一)
- java源码学习之HashMap(一)
- HashMap源码注解 之 成员变量(二)
- HashMap源码注解 之 内部数据结构 Node (三)
- HashMap源码注解 之 get()方法(五)
- HashMap源码注解 之 put()方法(六)
- HashMap源码注解 之 resize()方法(七)
- HashMap源码解读(一)
- HashMap源码分析(一)
- HashMap源码分析(一)
- HashMap源码解析(一)
- HashMap源码--(一)属性
- 一、(二) 常量定义
- HashMap源码注解 之 静态工具方法hash()、tableSizeFor()(四)
- C++之常量(一)
- C++之常量(一)
- c++之常量(一)
- C++之常量(一)
- Linux passwd --修改使用者的密码
- 每天laravel-20160709|CallEvent
- 关于产品的几个问题分析(来自京东产品经理笔试题)
- ChangePassword 控件(ASP.net)
- Nginx Location配置总结
- HashMap源码注解 之 常量定义(一)
- 大数据处理需要用到的九种编程语言
- HTML5标准格式
- 快速排序
- css中heght:100%不起作用的原由
- Linux pidof --找出正在运行程序的进程PID
- Head First Python 学习札记 2016-04-07
- 安装ipa
- Linux ping --测试与目标主机的连通性