HashMap、HashSet、红黑树

https://www.cnblogs.com/lycroseup/p/7324229.html

https://www.cnblogs.com/shoulinniao/p/11966194.html

HashMap 实现:

数组+链表+红黑树
链表长度超过8是转化为红黑树

HashMap与HashTable

HashMap线程不安全,HashTable线程安全(推荐使用ConcurrentHashMap)
HashMap初始容量16,负载因子0.75时扩容两倍;
HashTable初始容量11,负载因子0.75时扩容2倍+1;
红黑树的插入、删除和遍历的最坏时间复杂度都是log(n);

posted @ 2020-11-19 23:02  复一日  阅读(199)  评论(0编辑  收藏  举报