HashMap扩容
2021-03-18 00:12:15 6 举报
HashMap扩容的容量变化过程
作者其他创作
大纲/内容
oldCap >= MAXIMUM_CAPACITY ?
是
否
threshold = newThr;
threshold = Integer.MAX_VALUE; return oldTab;
newThr = oldThr << 1
oldCap > 0?
float ft = (float)newCap * loadFactor; newThr = (newCap < MAXIMUM_CAPACITY && ft < (float)MAXIMUM_CAPACITY ? (int)ft : Integer.MAX_VALUE);
oldThr > 0?
开始
结束
newCap = DEFAULT_INITIAL_CAPACITY;newThr = (int)(DEFAULT_LOAD_FACTOR * DEFAULT_INITIAL_CAPACITY);
newCap=oldThr
newThr == 0?
newCap<MAXIMUM_CAPACITY &&oldCap >= DEFAULT_INITIAL_CAPACITY
newCap = oldCap << 1
0 条评论
下一页