@ SuppressWarnings ( "unchecked" ) private void validateTable ( int targetRow ) { // TODO pooling of the arrays? if ( null == this . values ) { // nothing has been created yet int size = ( targetRow + 1 ) ; if ( SIZE_TABLE > size ) { size = SIZE_TABLE ; } this . values = ( V [ ] [ ] ) new Object [ size ] [ ] ; } else if ( targetRow >= this . values . length ) { // this row puts us beyond the current storage final int size = ( targetRow + 1 ) ; Object [ ] [ ] newTable = new Object [ size ] [ ] ; System . arraycopy ( this . values , 0 , newTable , 0 , this . values . length ) ; this . values = ( V [ ] [ ] ) newTable ; } else if ( null != this . values [ targetRow ] ) { // we already have this row created and are set return ; } // need to create the new row in the table this . values [ targetRow ] = ( V [ ] ) new Object [ SIZE_ROW ] ; for ( int i = 0 ; i < SIZE_ROW ; i ++ ) { this . values [ targetRow ] [ i ] = ( V ) NO_VALUE ; } }
Validate that the storage table contains the provided row . This will allocate new space if that is required .