com.google.common.primitives:八种原始类型和无符号类型的静态工具包
//在java8中可以被Integer.BYTES替代,代表字节数bytes
public static final int BYTES = Integer.SIZE / Byte.SIZE;
//int最大存储值,使用 1<<(Integer.SIZE-2) 计算得到,2是因为一位代表正负,1同时占一位
public static final int MAX_POWER_OF_TWO = 1 << (Integer.SIZE - 2);
public static int hashCode(int value) {
//int类型的hashcode是其本身
return value;
}
public static int indexOf(int[] array, int[] target) {
//这里进行了入参校验 可能是因为两个入参 如果报空指针则不知道是哪个参数引起的
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
return 0;
}
//...
}
public static int indexOf(int[] array, int target) {
return indexOf(array, target, 0, array