remove作为核心方法之一,也是我们需要掌握的重点,来看一下remove方法:
可以看出,remove方法中调用了removeNode方法,进去removeNode方法:
final Node<K,V> removeNode(int hash, Object key, Object value,
boolean matchValue, boolean movable) {
Node<K,V>[] tab; Node<K,V> p; int n, index;
//当table不为空,并且hash对应的桶不为空时
if ((tab = table) != null && (n = tab.length) > 0 &&
(p = tab[index = (n -