![JAR search and dependency download from the Maven repository](/logo.png)
com.jakewharton.Arrays Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of disklrucache Show documentation
Show all versions of disklrucache Show documentation
A disk-based implementaion of a least-recently used cache.
package com.jakewharton;
import java.lang.reflect.Array;
/* From java.util.Arrays */
class Arrays {
@SuppressWarnings("unchecked")
static T[] copyOfRange(T[] original, int start, int end) {
int originalLength = original.length; // For exception priority compatibility.
if (start > end) {
throw new IllegalArgumentException();
}
if (start < 0 || start > originalLength) {
throw new ArrayIndexOutOfBoundsException();
}
int resultLength = end - start;
int copyLength = Math.min(resultLength, originalLength - start);
T[] result = (T[]) Array.newInstance(original.getClass().getComponentType(), resultLength);
System.arraycopy(original, start, result, 0, copyLength);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy