@ Override public boolean add ( E value ) { final int hash ; int index ; if ( value == null ) { hash = 0 ; index = indexOfNull ( ) ; } else { hash = value . hashCode ( ) ; index = indexOf ( value , hash ) ; } if ( index >= 0 ) { return false ; } index = ~ index ; if ( mSize >= mHashes . length ) { final int n = mSize >= ( BASE_SIZE * 2 ) ? ( mSize + ( mSize >> 1 ) ) : ( mSize >= BASE_SIZE ? ( BASE_SIZE * 2 ) : BASE_SIZE ) ; if ( DEBUG ) Log . d ( TAG , "add: grow from " + mHashes . length + " to " + n ) ; final int [ ] ohashes = mHashes ; final Object [ ] oarray = mArray ; allocArrays ( n ) ; if ( mHashes . length > 0 ) { if ( DEBUG ) Log . d ( TAG , "add: copy 0-" + mSize + " to 0" ) ; System . arraycopy ( ohashes , 0 , mHashes , 0 , ohashes . length ) ; System . arraycopy ( oarray , 0 , mArray , 0 , oarray . length ) ; } freeArrays ( ohashes , oarray , mSize ) ; } if ( index < mSize ) { if ( DEBUG ) Log . d ( TAG , "add: move " + index + "-" + ( mSize - index ) + " to " + ( index + 1 ) ) ; System . arraycopy ( mHashes , index , mHashes , index + 1 , mSize - index ) ; System . arraycopy ( mArray , index , mArray , index + 1 , mSize - index ) ; } mHashes [ index ] = hash ; mArray [ index ] = value ; mSize ++ ; return true ; }
Adds the specified object to this set . The set is not modified if it already contains the object .