@Test public void testSliceOf() { short[] array = Shrt.array((short)0, (short)1, (short)2, (short)3, (short)4, (short)5, (short)6); short[] array2 = Shrt.sliceOf(array, 0, 100); Shrt.equalsOrDie(array, array2); }
@Universal public static short[] sliceOf( short[] 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 ) ); } short[] newArray = new short[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
Shrt { @Universal public static short[] sliceOf( short[] 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 ) ); } short[] newArray = new short[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; } }
Shrt { @Universal public static short[] sliceOf( short[] 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 ) ); } short[] newArray = new short[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }  }
Shrt { @Universal public static short[] sliceOf( short[] 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 ) ); } short[] newArray = new short[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }  static short[] shorts( short... array ); static short[] grow( short[] array, final int size ); static short[] grow( short[] array ); static short[] shrink( short[] array, int size ); static short[] compact( short[] array ); static short[] arrayOfShort( final int size ); @Universal static short[] array( final short... array ); @Universal static int len( short[] array ); @Universal static int lengthOf( short[] array ); @Universal static short idx( final short[] array, final int index ); @Universal static void idx( final short[] array, int index, short value ); @Universal static short[] slc( short[] array, int startIndex, int endIndex ); @Universal static short[] sliceOf( short[] array, int startIndex, int endIndex ); @Universal static short[] slc( short[] array, int startIndex ); @Universal static short[] sliceOf( short[] array, int startIndex ); @Universal static short[] endSliceOf( short[] array, int endIndex ); @Universal static short[] slcEnd( short[] array, int endIndex ); @Universal static boolean in( short value, short[] array ); @Universal static short[] copy( short[] array ); @Universal static short[] add( short[] array, short v ); @Universal static short[] add( short[] array, short[] array2 ); @Universal static short[] insert( final short[] array, final int idx, final short v ); @Universal static short[] insert( final short[] array, final int fromIndex, final short[] values ); static int reduceBy( final short[] array, Object object ); static boolean equalsOrDie(short[] expected, short[] got); static boolean equals(short[] expected, short[] got); }
Shrt { @Universal public static short[] sliceOf( short[] 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 ) ); } short[] newArray = new short[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }  static short[] shorts( short... array ); static short[] grow( short[] array, final int size ); static short[] grow( short[] array ); static short[] shrink( short[] array, int size ); static short[] compact( short[] array ); static short[] arrayOfShort( final int size ); @Universal static short[] array( final short... array ); @Universal static int len( short[] array ); @Universal static int lengthOf( short[] array ); @Universal static short idx( final short[] array, final int index ); @Universal static void idx( final short[] array, int index, short value ); @Universal static short[] slc( short[] array, int startIndex, int endIndex ); @Universal static short[] sliceOf( short[] array, int startIndex, int endIndex ); @Universal static short[] slc( short[] array, int startIndex ); @Universal static short[] sliceOf( short[] array, int startIndex ); @Universal static short[] endSliceOf( short[] array, int endIndex ); @Universal static short[] slcEnd( short[] array, int endIndex ); @Universal static boolean in( short value, short[] array ); @Universal static short[] copy( short[] array ); @Universal static short[] add( short[] array, short v ); @Universal static short[] add( short[] array, short[] array2 ); @Universal static short[] insert( final short[] array, final int idx, final short v ); @Universal static short[] insert( final short[] array, final int fromIndex, final short[] values ); static int reduceBy( final short[] array, Object object ); static boolean equalsOrDie(short[] expected, short[] got); static boolean equals(short[] expected, short[] got);  }