question: public void putAndEnsureCapacity ( long index , int value ) { int segment = ( int ) ( index > > > SEGMENT_BITS ) ; int position = ( int ) ( index & SEGMENT_MASK ) ; if ( segment >= segments . length ) { grow ( segment + 1 ) ; segments [ segment ] [ position ] = value ; if ( value != 0 ) numberOfNonZeroEntries ++ ; } else { final int old = segments [ segment ] [ position ] ; if ( old == 0 ) { if ( value != 0 ) { segments [ segment ] [ position ] = value ; numberOfNonZeroEntries ++ ; } } else { segments [ segment ] [ position ] = value ; if ( value == 0 ) numberOfNonZeroEntries -- ; } } maxIndex = Math . max ( maxIndex , index ) ; }
target:  put a value, If the index is larger than current maxIndex(), increases length of array