List of utility methods to do Array Swap
void | swapBytesAt(byte[] bytes, int p1, int p2) Swaps the bytes at the given positions. byte b = bytes[p1];
bytes[p1] = bytes[p2];
bytes[p2] = b;
|
void | swapElements(final E[] arr, final int idx1, final int idx2) swap Elements final E temp = arr[idx1];
arr[idx1] = arr[idx2];
arr[idx2] = temp;
|
byte[] | swapEndianFormat(byte[] b) swap Endian Format byte[] endianSwappedBytes = new byte[b.length]; for (int i = 0; i < b.length; i++) { endianSwappedBytes[i] = swapEndianFormat(b[i]); return endianSwappedBytes; |
int | swapInt(byte[] b, int i) swap Int return Integer.reverseBytes(bytesToInt(b, i));
|
byte[] | swapInts(byte b[], int off, int len) swap Ints checkLength(len, 4); for (int i = off, n = off + len; i < n; i += 4) { swap(b, i, i + 3); swap(b, i + 1, i + 2); return b; |
void | swapNumbers(int i, int j, double[] array) swap Numbers double temp;
temp = array[i];
array[i] = array[j];
array[j] = temp;
|
void | swapObjects(Object[] array, int a, int b) Swaps two Objects in an array of Objects. Object tmp = array[a]; array[a] = array[b]; array[b] = tmp; |
void | swapOrder16(byte[] buffer, int byteOffset, int sampleCount) swap Order int byteMax = sampleCount * 2 + byteOffset - 1; int i = byteOffset; while (i < byteMax) { byte h = buffer[i]; buffer[i] = buffer[++i]; buffer[i++] = h; |
void | swapOrder32(byte[] buffer, int byteOffset, int sampleCount) swap Order int byteMax = sampleCount * 4 + byteOffset - 3; int i = byteOffset; while (i < byteMax) { byte h = buffer[i]; buffer[i] = buffer[i + 3]; buffer[i + 3] = h; i++; h = buffer[i]; ... |
void | swapParallel(Object[] x, Object[] y, int a, int b, int yrel) swap Parallel Object tx = x[a], ty = y[a + yrel]; x[a] = x[b]; y[a + yrel] = y[b + yrel]; x[b] = tx; y[b + yrel] = ty; |