protected void resizeTo ( long newCapacity ) { final long oldCapacity = capacity ( ) ; final long oldAllocatedSize = HEADER_SIZE + oldCapacity * slotLength ; final MemoryAllocator oldMalloc ; final long oldAddress ; if ( auxMalloc != null ) { final long size = size ( ) ; oldAddress = move ( baseAddress , oldCapacity , malloc , auxMalloc ) ; oldMalloc = auxMalloc ; auxAllocateAndAdjustFields ( oldAddress , size , oldCapacity , newCapacity ) ; } else { oldMalloc = malloc ; oldAddress = baseAddress ; allocateArrayAndAdjustFields ( size ( ) , newCapacity ) ; } rehash ( oldCapacity , oldAddress ) ; oldMalloc . free ( oldAddress - HEADER_SIZE , oldAllocatedSize ) ; }
Allocates a new slot array with the requested size and moves all the assigned slots from the current array into the new one .