/** * Allocate internal buffers for a given capacity. * * @param capacity New capacity (must be a power of two). */ @SuppressWarnings("boxing") private void allocateBuffers(final int capacity) { try { final KType[] keys = Intrinsics.<KType>newArray(capacity); /*! #if ($RH) !*/ final int[] allocated = new int[capacity]; /*! #end !*/ this.keys = keys; /*! #if ($RH) !*/ this.hash_cache = allocated; /*! #end !*/ // allocate so that there is at least one slot that remains allocated = false // this is compulsory to guarantee proper stop in searching loops this.resizeAt = HashContainers.expandAtCount(capacity, this.loadFactor); } catch (final OutOfMemoryError e) { throw new BufferAllocationException( "Not enough memory to allocate buffers to grow from %d -> %d elements", e, (this.keys == null) ? 0 : this.keys.length, capacity); } }