private void rehash(){
  int size=_symbols.length;
  int newSize=size + size;
  if (newSize > MAX_TABLE_SIZE) {
    _size=0;
    Arrays.fill(_symbols,null);
    Arrays.fill(_buckets,null);
    _dirty=true;
    return;
  }
  String[] oldSyms=_symbols;
  Bucket[] oldBuckets=_buckets;
  _symbols=new String[newSize];
  _buckets=new Bucket[newSize >> 1];
  _indexMask=newSize - 1;
  _sizeThreshold+=_sizeThreshold;
  int count=0;
  for (int i=0; i < size; ++i) {
    String symbol=oldSyms[i];
    if (symbol != null) {
      ++count;
      int index=calcHash(symbol) & _indexMask;
      if (_symbols[index] == null) {
        _symbols[index]=symbol;
      }
 else {
        int bix=index >> 1;
        _buckets[bix]=new Bucket(symbol,_buckets[bix]);
      }
    }
  }
  size>>=1;
  for (int i=0; i < size; ++i) {
    Bucket b=oldBuckets[i];
    while (b != null) {
      ++count;
      String symbol=b.getSymbol();
      int index=calcHash(symbol) & _indexMask;
      if (_symbols[index] == null) {
        _symbols[index]=symbol;
      }
 else {
        int bix=index >> 1;
        _buckets[bix]=new Bucket(symbol,_buckets[bix]);
      }
      b=b.getNext();
    }
  }
  if (count != _size) {
    throw new Error("Internal error on SymbolTable.rehash(): had " + _size + " entries; now have "+ count+ ".");
  }
}

private void rehash ( ) { int size = _symbols . length ; int newSize = size + size ; if ( newSize > MAX_TABLE_SIZE ) { _size = 0 ; Arrays . fill ( _symbols , null ) ; Arrays . fill ( _buckets , null ) ; _dirty = true ; return ; } String [ ] oldSyms = _symbols ; Bucket [ ] oldBuckets = _buckets ; _symbols = new String [ newSize ] ; _buckets = new Bucket [ newSize > > 1 ] ; _indexMask = newSize - 1 ; _sizeThreshold += _sizeThreshold ; int count = 0 ; for ( int i = 0 ; i < size ; ++ i ) { String symbol = oldSyms [ i ] ; if ( symbol != null ) { ++ count ; int index = calcHash ( symbol ) & _indexMask ; if ( _symbols [ index ] == null ) { _symbols [ index ] = symbol ; } else { int bix = index > > 1 ; _buckets [ bix ] = new Bucket ( symbol , _buckets [ bix ] ) ; } } } size >>= 1 ; for ( int i = 0 ; i < size ; ++ i ) { Bucket b = oldBuckets [ i ] ; while ( b != null ) { ++ count ; String symbol = b . getSymbol ( ) ; int index = calcHash ( symbol ) & _indexMask ; if ( _symbols [ index ] == null ) { _symbols [ index ] = symbol ; } else { int bix = index > > 1 ; _buckets [ bix ] = new Bucket ( symbol , _buckets [ bix ] ) ; } b = b . getNext ( ) ; } } if ( count != _size ) { throw new Error ( "Internal error on SymbolTable.rehash(): had " + _size + " entries; now have " + count + "." ) ; } }
method called when size ( number of entries ) of symbol table grows so big that load factor is exceeded . since size has to remain power of two , arrays will then always be doubled . main work is really redistributing old entries into new string / bucket entries .
