public V put ( K key , V value ) { final int hash ; int index ; if ( key == null ) { hash = 0 ; index = indexOfNull ( ) ; } else { hash = key . hashCode ( ) ; index = indexOf ( key , hash ) ; } if ( index >= 0 ) { index = ( index << 1 ) + 1 ; final V old = ( V ) mArray [ index ] ; mArray [ index ] = value ; return old ; } index = ~ index ; if ( mSize >= mHashes . length ) { final int n = mSize >= ( BASE_SIZE * 2 ) ? ( mSize + ( mSize >> 1 ) ) : ( mSize >= BASE_SIZE ? ( BASE_SIZE * 2 ) : BASE_SIZE ) ; final int [ ] ohashes = mHashes ; final Object [ ] oarray = mArray ; allocArrays ( n ) ; if ( mHashes . length > 0 ) { System . arraycopy ( ohashes , 0 , mHashes , 0 , ohashes . length ) ; System . arraycopy ( oarray , 0 , mArray , 0 , oarray . length ) ; } freeArrays ( ohashes , oarray , mSize ) ; } if ( index < mSize ) { System . arraycopy ( mHashes , index , mHashes , index + 1 , mSize - index ) ; System . arraycopy ( mArray , index << 1 , mArray , ( index + 1 ) << 1 , ( mSize - index ) << 1 ) ; } mHashes [ index ] = hash ; mArray [ index << 1 ] = key ; mArray [ ( index << 1 ) + 1 ] = value ; mSize ++ ; return null ; }
Add a new value to the array map .