private HashMapEntry<K,V>[] doubleCapacity(){
  HashMapEntry<K,V>[] oldTable=table;
  int oldCapacity=oldTable.length;
  if (oldCapacity == MAXIMUM_CAPACITY) {
    return oldTable;
  }
  int newCapacity=oldCapacity * 2;
  HashMapEntry<K,V>[] newTable=makeTable(newCapacity);
  if (size == 0) {
    return newTable;
  }
  for (int j=0; j < oldCapacity; j++) {
    HashMapEntry<K,V> e=oldTable[j];
    if (e == null) {
      continue;
    }
    int highBit=e.hash & oldCapacity;
    HashMapEntry<K,V> broken=null;
    newTable[j | highBit]=e;
    for (HashMapEntry<K,V> n=e.next; n != null; e=n, n=n.next) {
      int nextHighBit=n.hash & oldCapacity;
      if (nextHighBit != highBit) {
        if (broken == null)         newTable[j | nextHighBit]=n;
 else         broken.next=n;
        broken=e;
        highBit=nextHighBit;
      }
    }
    if (broken != null)     broken.next=null;
  }
  return newTable;
}

private HashMapEntry < K , V > [ ] doubleCapacity ( ) { HashMapEntry < K , V > [ ] oldTable = table ; int oldCapacity = oldTable . length ; if ( oldCapacity == MAXIMUM_CAPACITY ) { return oldTable ; } int newCapacity = oldCapacity * 2 ; HashMapEntry < K , V > [ ] newTable = makeTable ( newCapacity ) ; if ( size == 0 ) { return newTable ; } for ( int j = 0 ; j < oldCapacity ; j ++ ) { HashMapEntry < K , V > e = oldTable [ j ] ; if ( e == null ) { continue ; } int highBit = e . hash & oldCapacity ; HashMapEntry < K , V > broken = null ; newTable [ j | highBit ] = e ; for ( HashMapEntry < K , V > n = e . next ; n != null ; e = n , n = n . next ) { int nextHighBit = n . hash & oldCapacity ; if ( nextHighBit != highBit ) { if ( broken == null ) newTable [ j | nextHighBit ] = n ; else broken . next = n ; broken = e ; highBit = nextHighBit ; } } if ( broken != null ) broken . next = null ; } return newTable ; }
doubles the capacity of the hash table . existing entries are placed in the correct bucket on the enlarged table . if the current capacity is , maximum_capacity , this method is a no - op . returns the table , which will be new unless we were already at maximum_capacity .
