### Question:
PrimitiveLongIntKeyValueArray { public boolean putIfAbsent( long key, int value ) { int capacity = naturalKeys.length; if ( size == capacity ) { ensureCapacity( (int) Math.floor( growthFactor * capacity ) ); } int index = Arrays.binarySearch( sortedKeys, 0, size, key ); if ( index >= 0 ) { return false; } else { index = -index - 1; for ( int i = size; i > index; i-- ) { int j = i - 1; sortedKeys[i] = sortedKeys[j]; sortedValues[i] = sortedValues[j]; } naturalKeys[size] = key; naturalValues[size] = value; sortedKeys[index] = key; sortedValues[index] = value; size += 1; return true; } } PrimitiveLongIntKeyValueArray( int initialCapacity, double growthFactor );  PrimitiveLongIntKeyValueArray( int initialCapacity );  PrimitiveLongIntKeyValueArray(); int capacity(); double growthFactor(); void ensureCapacity( int newCapacity ); int size(); int getOrDefault( long key, int defaultValue ); boolean putIfAbsent( long key, int value ); void reset( int newCapacity ); long[] keys(); static final int DEFAULT_INITIAL_CAPACITY; static final double DEFAULT_GROWTH_FACTOR; }### Answer:
@Test void testPutIfAbsent() { PrimitiveLongIntKeyValueArray map = new PrimitiveLongIntKeyValueArray(); assertThat( map.putIfAbsent( 1, 100 ), equalTo( true ) ); assertThat( map.putIfAbsent( 2, 200 ), equalTo( true ) ); assertThat( map.putIfAbsent( 3, 300 ), equalTo( true ) ); assertThat( map.size(), equalTo( 3 ) ); assertThat( map.keys(), equalTo( new long[]{1, 2, 3} ) ); assertThat( map.putIfAbsent( 2, 2000 ), equalTo( false ) ); assertThat( map.putIfAbsent( 3, 3000 ), equalTo( false ) ); assertThat( map.putIfAbsent( 4, 4000 ), equalTo( true ) ); assertThat( map.size(), equalTo( 4 ) ); assertThat( map.keys(), equalTo( new long[]{1, 2, 3, 4} ) ); assertThat( map.getOrDefault( 2, DEFAULT_VALUE ), equalTo( 200 ) ); assertThat( map.getOrDefault( 3, DEFAULT_VALUE ), equalTo( 300 ) ); assertThat( map.getOrDefault( 4, DEFAULT_VALUE ), equalTo( 4000 ) ); }