List of utility methods to do Array Sub Array
String[] | subarray(String[] master, int index) For an array master, returns an array containing the last master.length-index elements. if (master.length <= index) { return new String[0]; } else { String[] sub = new String[master.length - index]; System.arraycopy(master, index, sub, 0, sub.length); return sub; |
String[] | subArray(String[] strings, int nStart) sub Array String[] out = new String[strings.length - nStart + 1]; for (int i = nStart; i < strings.length; ++i) { out[i] = strings[i]; return out; |
T[] | subarray(T[] a, int off, int len) subarray return Arrays.copyOfRange(a, off, off + len);
|
T[] | subArray(T[] array, int start, int end) sub Array List<T> list = Arrays.asList(array);
return list.subList(start, end).toArray(array);
|
T[] | subArray(T[] array, int start, int end) Takes a sub array from element start to element end (end is excluded) return Arrays.copyOfRange(array, start, end);
|
T[] | subArray(T[] array, int startIndex, int endIndex) Construct a sub array from the startIndex (inclusive) to the endIndex (exclusive). List<T> subArray = new ArrayList<T>(); for (int i = startIndex; i < endIndex; i++) { subArray.add(array[i]); return subArray.toArray(Arrays.copyOf(array, 0)); |
T[] | subArray(T[] origin, int start, int length) sub Array return subList(origin, start, length).toArray(origin);
|
double[] | subarrayChar2Double(char[] orig, int off, int len) subarray Char Double if (off + len > orig.length) throw new IllegalArgumentException("requested subarray exceeds array length"); double[] sub = new double[len]; for (int i = 0; i < len; i++) sub[i] = orig[i + off]; return sub; |
byte[] | subarrayEnd(byte[] array, int offset) NOTE: subarray method implemented for arrays of type byte subarray method that makes an array copy of the original array starting at offset and ending at the end of the original array. return subarray(array, offset, array.length - offset);
|
boolean | subarrayEquals(int[] array, int[] subarray, int startIndex) subarray Equals for (int i = 0; i < subarray.length; i++) { if (array[i + startIndex] != subarray[i]) { return false; return true; |