@Universal public static <V> V[] slcEnd( V[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "end index %d, length %d", endIndex, array.length ) ); } Object newArray = Array.newInstance( array.getClass().getComponentType(), newLength ); System.arraycopy( array, 0, newArray, 0, newLength ); return ( V[] ) newArray; }
@Universal public static <V> V[] slcEnd( V[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "end index %d, length %d", endIndex, array.length ) ); } Object newArray = Array.newInstance( array.getClass().getComponentType(), newLength ); System.arraycopy( array, 0, newArray, 0, newLength ); return ( V[] ) newArray; }
@Universal public static <V> V[] slcEnd( V[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "end index %d, length %d", endIndex, array.length ) ); } Object newArray = Array.newInstance( array.getClass().getComponentType(), newLength ); System.arraycopy( array, 0, newArray, 0, newLength ); return ( V[] ) newArray; }
@Universal public static <V> V[] slc( V[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); final int newLength = end - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, end index %d, length %d", startIndex, endIndex, array.length ) ); } Object newArray = Array.newInstance( array.getClass().getComponentType(), newLength ); System.arraycopy( array, start, newArray, 0, newLength ); return ( V[] ) newArray; }
@Universal public static <V> V[] slc( V[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); final int newLength = end - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, end index %d, length %d", startIndex, endIndex, array.length ) ); } Object newArray = Array.newInstance( array.getClass().getComponentType(), newLength ); System.arraycopy( array, start, newArray, 0, newLength ); return ( V[] ) newArray; }
@Universal public static <V> V[] slc( V[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); final int newLength = end - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, end index %d, length %d", startIndex, endIndex, array.length ) ); } Object newArray = Array.newInstance( array.getClass().getComponentType(), newLength ); System.arraycopy( array, start, newArray, 0, newLength ); return ( V[] ) newArray; }