@Test public void testSliceOf() { long[] array = Lng.array(0, 1, 2, 3, 4, 5, 6); long[] array2 = Lng.sliceOf(array, 0, 100); Lng.equalsOrDie(array, array2); }
@Universal public static long[] sliceOf( long[] 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 ) ); } long[] newArray = new long[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
Lng { @Universal public static long[] sliceOf( long[] 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 ) ); } long[] newArray = new long[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; } }
Lng { @Universal public static long[] sliceOf( long[] 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 ) ); } long[] newArray = new long[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }  }
Lng { @Universal public static long[] sliceOf( long[] 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 ) ); } long[] newArray = new long[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }  static String str( long value ); static long[] grow( long[] array, final int size ); static long[] grow( long[] array ); static long[] shrink( long[] array, int size ); static long[] compact( long[] array ); static long[] arrayOfLong( final int size ); @Universal static long[] array( final long... array ); @Universal static int len( long[] array ); @Universal static int lengthOf( long[] array ); @Universal static long idx( final long[] array, final int index ); @Universal static long atIndex( final long[] array, final int index ); @Universal static void idx( final long[] array, int index, long value ); @Universal static void atIndex( final long[] array, int index, long value ); @Universal static long[] slc( long[] array, int startIndex, int endIndex ); @Universal static long[] sliceOf( long[] array, int startIndex, int endIndex ); @Universal static long[] slc( long[] array, int startIndex ); @Universal static long[] sliceOf( long[] array, int startIndex ); @Universal static long[] slcEnd( long[] array, int endIndex ); @Universal static long[] endSliceOf( long[] array, int endIndex ); @Universal static boolean in( long value, long[] array ); @Universal static long[] copy( long[] array ); @Universal static long[] add( long[] array, long v ); @Universal static long[] add( long[] array, long[] array2 ); @Universal static long[] insert( final long[] array, final int idx, final long v ); @Universal static long[] insert( final long[] array, final int fromIndex, final long[] values ); static long reduceBy( final long[] array, ReduceBy reduceBy ); static long reduceBy( final long[] array, final int start, final int length, ReduceBy reduceBy ); static long reduceBy( final long[] array, final int length, ReduceBy reduceBy ); static long reduceBy( final long[] array, T object ); static long reduceBy( final long[] array, T object, String methodName ); static long reduceBy( final long[] array,  int length,
                                 Object object ); static long reduceBy( final long[] array,  int length,
                                 Object function, String functionName ); static long reduceBy( final long[] array, int start, int length,
                                 Object object ); static boolean equalsOrDie(long expected, long got); static boolean equals(long expected, long got); static long sum( long[] values ); static long sum( long[] values,  int length ); static long sum( long[] values, int start, int length ); static long max( long[] values, final int start, final int length ); static long max( long[] values ); static long max( long[] values, int length ); static long min( long[] values, final int start, final int length ); static long min( long[] values ); static long min( long[] values, int length ); static long mean( long[] values, final int start, final int length ); static long mean( long[] values, final int length ); static long mean( long[] values ); static long variance(long[] values, final int start, final int length); static double meanDouble( long[] values, final int start, final int length ); static double varianceDouble(long[] values, final int start, final int length); static long variance(long[] values,  final int length); static long variance(long[] values); static long standardDeviation(long[] values, final int start, final int length); static long standardDeviation(long[] values,  final int length); static int standardDeviation(long[] values); static long median(long[] values, final int start, final int length); static long median(long[] values, final int length); static long median(long[] values); static boolean equalsOrDie(long[] expected, long[] got); static boolean equals(long[] expected, long[] got); static boolean equals(int start, int end, long[] expected, long[] got); static int hashCode(long array[]); static int hashCode(int start, int end, long array[]); }
Lng { @Universal public static long[] sliceOf( long[] 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 ) ); } long[] newArray = new long[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }  static String str( long value ); static long[] grow( long[] array, final int size ); static long[] grow( long[] array ); static long[] shrink( long[] array, int size ); static long[] compact( long[] array ); static long[] arrayOfLong( final int size ); @Universal static long[] array( final long... array ); @Universal static int len( long[] array ); @Universal static int lengthOf( long[] array ); @Universal static long idx( final long[] array, final int index ); @Universal static long atIndex( final long[] array, final int index ); @Universal static void idx( final long[] array, int index, long value ); @Universal static void atIndex( final long[] array, int index, long value ); @Universal static long[] slc( long[] array, int startIndex, int endIndex ); @Universal static long[] sliceOf( long[] array, int startIndex, int endIndex ); @Universal static long[] slc( long[] array, int startIndex ); @Universal static long[] sliceOf( long[] array, int startIndex ); @Universal static long[] slcEnd( long[] array, int endIndex ); @Universal static long[] endSliceOf( long[] array, int endIndex ); @Universal static boolean in( long value, long[] array ); @Universal static long[] copy( long[] array ); @Universal static long[] add( long[] array, long v ); @Universal static long[] add( long[] array, long[] array2 ); @Universal static long[] insert( final long[] array, final int idx, final long v ); @Universal static long[] insert( final long[] array, final int fromIndex, final long[] values ); static long reduceBy( final long[] array, ReduceBy reduceBy ); static long reduceBy( final long[] array, final int start, final int length, ReduceBy reduceBy ); static long reduceBy( final long[] array, final int length, ReduceBy reduceBy ); static long reduceBy( final long[] array, T object ); static long reduceBy( final long[] array, T object, String methodName ); static long reduceBy( final long[] array,  int length,
                                 Object object ); static long reduceBy( final long[] array,  int length,
                                 Object function, String functionName ); static long reduceBy( final long[] array, int start, int length,
                                 Object object ); static boolean equalsOrDie(long expected, long got); static boolean equals(long expected, long got); static long sum( long[] values ); static long sum( long[] values,  int length ); static long sum( long[] values, int start, int length ); static long max( long[] values, final int start, final int length ); static long max( long[] values ); static long max( long[] values, int length ); static long min( long[] values, final int start, final int length ); static long min( long[] values ); static long min( long[] values, int length ); static long mean( long[] values, final int start, final int length ); static long mean( long[] values, final int length ); static long mean( long[] values ); static long variance(long[] values, final int start, final int length); static double meanDouble( long[] values, final int start, final int length ); static double varianceDouble(long[] values, final int start, final int length); static long variance(long[] values,  final int length); static long variance(long[] values); static long standardDeviation(long[] values, final int start, final int length); static long standardDeviation(long[] values,  final int length); static int standardDeviation(long[] values); static long median(long[] values, final int start, final int length); static long median(long[] values, final int length); static long median(long[] values); static boolean equalsOrDie(long[] expected, long[] got); static boolean equals(long[] expected, long[] got); static boolean equals(int start, int end, long[] expected, long[] got); static int hashCode(long array[]); static int hashCode(int start, int end, long array[]);  }