/** * Clear the array and set a new capacity if not already large enough. * * @param newCapacity the new capacity requirement */ public void reset( int newCapacity ) { size = 0; ensureCapacity( newCapacity ); }
if ( size == capacity ) ensureCapacity( (int) Math.floor( growthFactor * capacity ) );
@Test void testEnsureCapacity() { PrimitiveLongIntKeyValueArray map = new PrimitiveLongIntKeyValueArray(); assertThat( map.capacity(), equalTo( PrimitiveLongIntKeyValueArray.DEFAULT_INITIAL_CAPACITY ) ); map.ensureCapacity( 10 ); assertThat( map.capacity(), greaterThanOrEqualTo( 10 ) ); map.ensureCapacity( 100 ); assertThat( map.capacity(), greaterThanOrEqualTo( 100 ) ); map.ensureCapacity( 1000 ); assertThat( map.capacity(), greaterThanOrEqualTo( 1000 ) ); }
/** * Clear the array and set a new capacity if not already large enough. * * @param newCapacity the new capacity requirement */ public void reset( int newCapacity ) { size = 0; ensureCapacity( newCapacity ); }
/** * Clear the array and set a new capacity if not already large enough. * * @param newCapacity the new capacity requirement */ public void reset( int newCapacity ) { size = 0; ensureCapacity( newCapacity ); }
if ( size == capacity ) ensureCapacity( (int) Math.floor( growthFactor * capacity ) );
if ( size == capacity ) ensureCapacity( (int) Math.floor( growthFactor * capacity ) );