/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] endSliceOf( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] slcEnd( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] slcEnd( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] slcEnd( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] endSliceOf( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] endSliceOf( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] sliceOf( int[] 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 ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] sliceOf( int[] 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 ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] slc( int[] 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 ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] sliceOf( int[] 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 ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] slc( int[] 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 ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ @Universal public static int[] slc( int[] 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 ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }