Java Utililty Methods Array Swap

List of utility methods to do Array Swap

Description

The list of methods to do Array Swap are organized into topic(s).

Method

double[]swap(double[] a, int i, int j)
Swap two elements in the double vector
double temp = a[i];
a[i] = a[j];
a[j] = temp;
return a;
voidswap(double[] array, int i, int j)
swap
double tmp = array[i];
array[i] = array[j];
array[j] = tmp;
voidswap(double[] data, int i, int j)
swap
double tmp = data[i];
data[i] = data[j];
data[j] = tmp;
voidswap(final byte[] array, int firstIndex, int secondIndex)
swap
final byte tmp = array[firstIndex];
array[firstIndex] = array[secondIndex];
array[secondIndex] = tmp;
byte[]swap(final byte[] src)
swap
final byte[] dst = new byte[src.length];
for (int i = 0; i < src.length; i++) {
    dst[dst.length - i - 1] = src[i];
return dst;
voidswap(final float[] pVertices, final int pVertexStride, final int pVertexIndexA, final int pVertexIndexB)
swap
final int vertexOffsetA = pVertexIndexA * pVertexStride;
final int vertexOffsetB = pVertexIndexB * pVertexStride;
for (int i = pVertexStride - 1; i >= 0; i--) {
    final float tmp = pVertices[vertexOffsetA + i];
    pVertices[vertexOffsetA + i] = pVertices[vertexOffsetB + i];
    pVertices[vertexOffsetB + i] = tmp;
voidswap(final int a[], final int i, final int j)
Used by the quick sort and quick select algorithms.
final int T;
T = a[i];
a[i] = a[j];
a[j] = T;
voidswap(final int[] array, final int i, final int j)
Swaps the elements at the specified positions in the specified array.
final int temp = array[i];
array[i] = array[j];
array[j] = temp;
voidswap(final int[] array, final int indexA, final int indexB)
swap
int t = array[indexA];
array[indexA] = array[indexB];
array[indexB] = t;
voidswap(final int[] array, final int pos1, final int pos2)
Swaps two elements in the array.
final int temp = array[pos1];
array[pos1] = array[pos2];
array[pos2] = temp;