List of utility methods to do Integer Create
int[] | toIntArray(boolean[] array) Coverts given booleans array to array of ints. int[] result = new int[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i] ? 1 : 0; return result; |
int[] | toIntArray(boolean[] selectedValues) to Int Array int numValues = 0; for (boolean value : selectedValues) { if (value) { numValues++; int[] intValues = new int[numValues]; int numValue = 0; ... |
int[] | toIntArray(byte[] byteArray) to Int Array if (byteArray == null || byteArray.length % 4 != 0) return null; int[] ints = new int[byteArray.length / 4]; for (int i = 0; i < ints.length; i++) { ints[i] = toInt(new byte[] { byteArray[(i * 4)], byteArray[(i * 4) + 1], byteArray[(i * 4) + 2], byteArray[(i * 4) + 3], }); return ints; ... |
int[] | toIntArray(byte[] bytes) to Int Array int[] dst = new int[bytes.length / 2]; for (int i = 0, j = 0; i < dst.length; i++, j += 2) dst[i] = ((bytes[j] & 0xff) << 8) | (bytes[j + 1] & 0xff); return dst; |
int[] | toIntArray(byte[] data) Convenience method to create an int[] array from a byte[] array. int[] result = new int[data.length / 4]; byte[] tmp = new byte[4]; for (int i = 0; i < result.length; i++) { System.arraycopy(data, i * 4, tmp, 0, 4); result[i] = toInt(tmp); return result; |
int[] | toIntArray(byte[] data) to Int Array if ((data == null) || (data.length % 4 != 0)) { return null; int[] ints = new int[data.length / 4]; for (int i = 0; i < ints.length; i++) { ints[i] = toInt(new byte[] { data[(i * 4)], data[(i * 4) + 1], data[(i * 4) + 2], data[(i * 4) + 3], }); return ints; ... |
int[] | toIntArray(byte[] data, boolean includeLength) to Int Array int n = (((data.length & 3) == 0) ? (data.length >>> 2) : ((data.length >>> 2) + 1)); int[] result; if (includeLength) { result = new int[n + 1]; result[n] = data.length; } else { result = new int[n]; n = data.length; for (int i = 0; i < n; ++i) { result[i >>> 2] |= (0x000000ff & data[i]) << ((i & 3) << 3); return result; |
int[] | toIntArray(byte[] data, int offset) to Int Array int length = toInt(data, offset); offset += 4; int[] arr = new int[length]; for (int i = 0; i < length; i++) { arr[i] = toInt(data, offset); offset += 4; return arr; ... |
int[] | toIntArray(byte[] input) Rewrite a byte array as an int array (the array can be padded with zeros) int[] result = new int[(input.length + 3) >>> 2]; int index, shiftpos; for (int i = 0; i < input.length; i++) { index = i >>> 2; shiftpos = i % 4; result[index] ^= (input[i] & 0xff) << (8 * shiftpos); return result; ... |
int[] | toIntArray(double[] a) Converts a double array to an int array. int[] b = new int[a.length]; for (int i = 0; i < a.length; i++) { b[i] = (int) a[i]; return b; |