源码笔记
十四说四十、
一只努力搬砖的985小硕
展开
-
Go channel源码解读
下面是channel 的源码type hchan struct { qcount uint // total data in the queue 队列中当前数据个数=len(chan) dataqsiz uint // size of the circular queue channel的大小=cap(chan) //如果 qcount 和 dataqsiz 的值相同,则表示缓冲区用完了。 buf unsafe.Pointer // po原创 2020-07-11 01:25:31 · 340 阅读 · 0 评论 -
ConcurrentHashMap源码
目录put逻辑初始化桶扩容逻辑put逻辑//onlyIfAbsent 默认传的falsefinal V putVal(K key, V value, boolean onlyIfAbsent) { //如果put的key或者 value 为空那么抛出异常 if (key == null || value == null) throw new NullPointerException(); //得到hash值 int hash = spread(key原创 2020-07-30 19:54:53 · 93 阅读 · 0 评论 -
Java集合源码 - HahMap
首先看一下HashMap的类定义public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable 1.属性//默认初始容量为16static final int DEFAULT_INITIAL_CAPACITY = 1 ...原创 2019-12-14 15:27:31 · 97 阅读 · 0 评论 -
Java 集合源码 - ArrayList
public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable //RandomAccess 代表支持随机访问DEFAULT_CAPACITY 代表的是数组的初...原创 2019-12-13 22:48:50 · 70 阅读 · 0 评论