@see Arrays#copyOf(Object[], int, Class)

@param original
@param newLength
@return
548181
public static <T, U> T[] copyOf(final U[] original, final int newLength, final Class<? extends T[]> newType) {
        final T[] copy = Object[].class.equals(newType) ? (T[]) new Object[newLength] : (T[]) N.newArray(newType.getComponentType(), newLength);

        if (N.notNullOrEmpty(original)) {
            copy(original, 0, copy, 0, Math.min(original.length, newLength));
        }

        return copy;
    }
1344331
public static byte[] copyOf(byte[] src, int length) {
        byte[] dest = new byte[length];
        System.arraycopy(src, 0, dest, 0, Math.min(src.length, length));
        return dest;
    }
630089
public static final byte[] cloneSubArray(byte[] data, int offset, int size)
   {
      byte[] newData = new byte[size];
      System.arraycopy(data, offset, newData, 0, size);
      return (newData);
   }
344124
static <T> T[] arraysCopyOf(T[] original, int newLength) {
    T[] copy = newArray(original, newLength);
    System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
    return copy;
  }
88781
public static float[] copyOfRange(final float[] original, final int from, final int to) {
        if (from == 0 && to == original.length) {
            return original.clone();
        }

        final int newLength = to - from;
        final float[] copy = new float[newLength];
        copy(original, from, copy, 0, Math.min(original.length - from, newLength));
        return copy;
    }
767463
int reallocate(int index, int offset, int oldLen, int newLen) {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "reallocate", new Object[]{Integer.valueOf(index), Integer.valueOf(offset), Integer.valueOf(oldLen), Integer.valueOf(newLen)});

    // Get oTable index for the next field after this one, if any. We can be
    // guaranteed that its offsetIndex is one greater than ours, since this is a
    // varying length field.
    int oInx = map.fields[index].offsetIndex + 1;

    // Update the oTable in place
    while (oInx < oTable.length) {
      oTable[oInx++] += (newLen - oldLen);
    }

    // Compute the length of the balance, after the varying length field
    int balance = (messageOffset + length) - offset - 4 - oldLen;

    // Create new contents entry, and update related offsets and lengths
    byte[] oldcontents = contents;
    int oldMessageOffset = messageOffset;
    int oldDataOffset = dataOffset;
    int oldTableOffset = tableOffset;
    length += (newLen - oldLen);
    contents = new byte[length];
    messageOffset = 0;
    tableOffset = dataOffset = oldTableOffset - oldMessageOffset;

    // Copy the schemata ids
    System.arraycopy(oldcontents, oldMessageOffset, contents, 0, tableOffset);

    // Write the offset table into the new array
    for (int i = 0; i < oTable.length; i++) {
      ArrayUtil.writeInt(contents, dataOffset, oTable[i]);
      dataOffset += 4;
    }

    // Copy up to the point where the length is changing
    System.arraycopy(oldcontents, oldDataOffset, contents, dataOffset, offset - oldDataOffset);

    // Copy balance of data after varying length field
    if (balance > 0) {
      System.arraycopy(oldcontents, offset + 4 + oldLen, contents, length - balance, balance);
    }

    reallocated = true;

    // We have a new contents buffer, so it can't be shared
    sharedContents = false;

    // Ensure any dependent JSMessageData parts in the cache are updated.
    reallocated(contents, -1);

    int result = offset - oldMessageOffset;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "reallocate", Integer.valueOf(result));
    return result;
  }
676175
protected int expand(int len) {
        int newcount = count + len;
        if (newcount <= content.length) return 0;
        byte[] newdata = new byte[Math.max(content.length * 3 / 2, newcount)];
        System.arraycopy(content, 0, newdata, 0, count);
        this.content = newdata;
        return 0;
    }
103066
public void addReplace(int oldLength, int newLength) {
        if(oldLength == newLength && 0 < oldLength && oldLength <= MAX_SHORT_WIDTH) {
            // Replacement of short oldLength text units by same-length new text.
            // Merge into previous short-replacement record, if any.
            int last = lastUnit();
            if(MAX_UNCHANGED < last && last < MAX_SHORT_CHANGE &&
                    (last >> 12) == oldLength && (last & 0xfff) < MAX_SHORT_CHANGE_LENGTH) {
                setLastUnit(last + 1);
                return;
            }
            append(oldLength << 12);
            return;
        }

        if(oldLength < 0 || newLength < 0) {
            throw new IllegalArgumentException(
                    "addReplace(" + oldLength + ", " + newLength +
                    "): both lengths must be non-negative");
        }
        if (oldLength == 0 && newLength == 0) {
            return;
        }
        int newDelta = newLength - oldLength;
        if (newDelta != 0) {
            if ((newDelta > 0 && delta >= 0 && newDelta > (Integer.MAX_VALUE - delta)) ||
                    (newDelta < 0 && delta < 0 && newDelta < (Integer.MIN_VALUE - delta))) {
                // Integer overflow or underflow.
                throw new IndexOutOfBoundsException();
            }
            delta += newDelta;
        }

        int head = 0x7000;
        if (oldLength < LENGTH_IN_1TRAIL && newLength < LENGTH_IN_1TRAIL) {
            head |= oldLength << 6;
            head |= newLength;
            append(head);
        } else if ((array.length - length) >= 5 || growArray()) {
            int limit = length + 1;
            if(oldLength < LENGTH_IN_1TRAIL) {
                head |= oldLength << 6;
            } else if(oldLength <= 0x7fff) {
                head |= LENGTH_IN_1TRAIL << 6;
                array[limit++] = (char)(0x8000 | oldLength);
            } else {
                head |= (LENGTH_IN_2TRAIL + (oldLength >> 30)) << 6;
                array[limit++] = (char)(0x8000 | (oldLength >> 15));
                array[limit++] = (char)(0x8000 | oldLength);
            }
            if(newLength < LENGTH_IN_1TRAIL) {
                head |= newLength;
            } else if(newLength <= 0x7fff) {
                head |= LENGTH_IN_1TRAIL;
                array[limit++] = (char)(0x8000 | newLength);
            } else {
                head |= LENGTH_IN_2TRAIL + (newLength >> 30);
                array[limit++] = (char)(0x8000 | (newLength >> 15));
                array[limit++] = (char)(0x8000 | newLength);
            }
            array[length] = (char)head;
            length = limit;
        }
    }
172869
public void getBytes(int lengthToCopy, byte[] copyArray, int copyOffset) {
        if (lengthToCopy > 0) {
            System.arraycopy(_buffer, _offset, copyArray, copyOffset, lengthToCopy);
            skip(lengthToCopy);
        }

    }
738605
public static int[] copyOf(int[] old, int length) {
    int[] newArray = new int[length];
    int minLength = Math.min(old.length, length);
    System.arraycopy(old, 0, newArray, 0, minLength);
    return newArray;
  }
113809
function ensureLength (self, _newLength) {
  var newLength;
  if (_newLength > MAX_LENGTH) {
    newLength = MAX_LENGTH;
  } else {
    newLength = _newLength | 0;
  }
  var proto = Object.getPrototypeOf(self);
  var cur = proto[length] | 0;
  var num = newLength - cur;
  if (num > 0) {
    var desc = {};
    debug('creating a descriptor object with %o entries', num);
    for (var i = cur; i < newLength; i++) {
      desc[i] = setup(i);
    }
    debug('calling `Object.defineProperties()` with %o entries', num);
    Object.defineProperties(proto, desc);
    proto[length] = newLength;
  }
  return newLength;
}
818676
public static byte[] safeCopy(byte[] source, int offset, int length) {
    if (length < 0 || source.length < offset+length) {
      return null;
    }
    byte[] copy = new byte[length];
    System.arraycopy(source, offset, copy, 0, length);
    return copy;
  }
1016787
private List<List<Double>> deepCopy(final List<List<Double>> original) {
    final List<List<Double>> result = new ArrayList<>(original.size());
    for (final List<Double> originalRow : original) {
      final List<Double> row = new ArrayList<>(originalRow.size());
      for (final double element : originalRow) {
        row.add(element);
      }
      result.add(row);
    }
    return result;
  }
419150
private void resizeElementArrays(int dataLength, int newLength) {

        Object temp;
        int    usedLength = newLength > dataLength ? dataLength
                                                   : newLength;

        if (isIntKey) {
            temp        = intKeyTable;
            intKeyTable = new int[newLength];

            System.arraycopy(temp, 0, intKeyTable, 0, usedLength);
        }

        if (isIntValue) {
            temp          = intValueTable;
            intValueTable = new int[newLength];

            System.arraycopy(temp, 0, intValueTable, 0, usedLength);
        }

        if (isLongKey) {
            temp         = longKeyTable;
            longKeyTable = new long[newLength];

            System.arraycopy(temp, 0, longKeyTable, 0, usedLength);
        }

        if (isLongValue) {
            temp           = longValueTable;
            longValueTable = new long[newLength];

            System.arraycopy(temp, 0, longValueTable, 0, usedLength);
        }

        if (isObjectKey) {
            temp           = objectKeyTable;
            objectKeyTable = new Object[newLength];

            System.arraycopy(temp, 0, objectKeyTable, 0, usedLength);
        }

        if (isObjectValue) {
            temp             = objectValueTable;
            objectValueTable = new Object[newLength];

            System.arraycopy(temp, 0, objectValueTable, 0, usedLength);
        }

        if (accessTable != null) {
            temp        = accessTable;
            accessTable = new int[newLength];

            System.arraycopy(temp, 0, accessTable, 0, usedLength);
        }

        if (multiValueTable != null) {
            temp            = multiValueTable;
            multiValueTable = new boolean[newLength];

            System.arraycopy(temp, 0, multiValueTable, 0, usedLength);
        }
    }
517898
public static byte[][] copyOf(final byte[][] a, final int s) {
        final byte[][] tmp = new byte[s][];
        System.arraycopy(a, 0, tmp, 0, Math.min(s, a.length));
        return tmp;
    }
412109
private static char[] copyOf(char[] original, int length) {
    char[] copy = new char[length];
    System.arraycopy(original, 0, copy, 0, Math.min(original.length, length));
    return copy;
  }
594178
public static long[] copyOf(long[] longArray) {

    	long[] copy = new long[longArray.length];
        System.arraycopy(longArray, 0, copy, 0, longArray.length);
        return copy;
    }