Android Utililty Methods Array Copy

List of utility methods to do Array Copy

Description

The list of methods to do Array Copy are organized into topic(s).

Method

voidarraycopy(byte[] src, int src_position, byte[] dst, int dst_position, int length)
This is really a debugging version of System.arraycopy().
if (src_position < 0)
    throw new IllegalArgumentException(
            "src_position was less than 0.  Actual value "
                    + src_position);
if (src_position >= src.length)
    throw new IllegalArgumentException(
            "src_position was greater than src array size.  Tried to write starting at position "
                    + src_position
...
double[]copy(double[] dataToCopy)
copy
if (dataToCopy == null) {
    return null;
double[] ret = new double[dataToCopy.length];
System.arraycopy(dataToCopy, 0, ret, 0, dataToCopy.length);
return ret;
ObjectcopyArrayGrow1(Object array, Class newArrayComponentType)
Returns a copy of the given array of size 1 greater than the argument.
if (array != null) {
    int arrayLength = Array.getLength(array);
    Object newArray = Array.newInstance(array.getClass()
            .getComponentType(), arrayLength + 1);
    System.arraycopy(array, 0, newArray, 0, arrayLength);
    return newArray;
return Array.newInstance(newArrayComponentType, 1);
...
ObjectcopyOf(Object src)
copy Of
int srcLength = Array.getLength(src);
Class<?> srcComponentType = src.getClass().getComponentType();
Object dest = Array.newInstance(srcComponentType, srcLength);
if (srcComponentType.isArray()) {
    for (int i = 0; i < Array.getLength(src); i++) {
        Array.set(dest, i, copyOf(Array.get(src, i)));
} else {
...
String[]copyOf(String[] obj)
copy Of
return copyOf(obj, obj.length);
String[]copyOf(String[] obj, int newSize)
copy Of
String tempArr[] = new String[newSize];
System.arraycopy(obj, 0, tempArr, 0, Math.min(obj.length, newSize));
return tempArr;
T[]copyOf(T[] original)
Copy the specified array.
return (T[]) copyOf(original, original.length);
T[]copyOf(T[] original, int newLength)
Copy the specified array.
T[] copy = (T[]) new Object[newLength];
System.arraycopy(original, 0, copy, 0,
        Math.min(original.length, newLength));
return copy;
T[]copyOf(T[] source, T[] result)
Copies the specified array into specified result array, truncating or padding with zeros (if necessary) so the copy has the specified length.
System.arraycopy(source, 0, result, 0,
        Math.min(source.length, result.length));
return result;
boolean[]copyOf(boolean[] obj)
copy Of
return copyOf(obj, obj.length);