/** * Returns a copy of a portion of an array. * * @param array an array. * @param offset the first element to copy. * @param length the number of elements to copy. * @return a new array containing <code>length</code> elements of <code>array</code> starting at * <code>offset</code>. */ public static long[] copy(final long[] array, final int offset, final int length) { ensureOffsetLength(array, offset, length); final long[] a = length == 0 ? EMPTY_ARRAY : new long[length]; System.arraycopy(array, offset, a, 0, length); return a; }
/** * Creates a new tree set and fills it with the elements of a given array using a given {@link * Comparator}. * * @param a an array whose elements will be used to fill the set. * @param offset the first element to use. * @param length the number of elements to use. * @param c a {@link Comparator} (even better, a type-specific comparator). */ public LongAVLTreeSet( final long[] a, final int offset, final int length, final Comparator<? super Long> c) { this(c); LongArrays.ensureOffsetLength(a, offset, length); for (int i = 0; i < length; i++) add(a[offset + i]); }