public void growArray ( int length ) { // now need to grow since it is already larger if ( this . data . length >= length ) return ; T [ ] data = ( T [ ] ) Array . newInstance ( type , length ) ; System . arraycopy ( this . data , 0 , data , 0 , this . data . length ) ; if ( factory != null ) { for ( int i = this . data . length ; i < length ; i ++ ) { data [ i ] = createInstance ( ) ; } } this . data = data ; }
Increases the size of the internal array without changing the shape s size . If the array is already larger than the specified length then nothing is done . Elements previously stored in the array are copied over is a new internal array is declared .