@ SuppressWarnings ( "unchecked" ) private void validateKey ( int index ) { final int size = ( index + 1 ) ; if ( null == this . keys ) { // nothing has been created yet this . keys = ( K [ ] ) new Object [ size ] ; } else if ( index >= this . keys . length ) { // this row puts us beyond the current storage Object [ ] newKeys = new Object [ size ] ; System . arraycopy ( this . keys , 0 , newKeys , 0 , this . keys . length ) ; this . keys = ( K [ ] ) newKeys ; } }
Ensure that we have space in the local key array for the target index .