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

voidswap(int[] array)
Swaps the two integers in the array.
int tmp;
if (array.length == 2) {
    tmp = array[0];
    array[0] = array[1];
    array[1] = tmp;
voidswap(int[] array, int i, int j)
swap
if (i == j)
    return;
int old = array[i];
array[i] = array[j];
array[j] = old;
voidswap(int[] array, int idx1, int idx2)
swap
if (idx1 != idx2) {
    array[idx1] = array[idx1] + array[idx2];
    array[idx2] = array[idx1] - array[idx2];
    array[idx1] = array[idx1] - array[idx2];
voidswap(int[] array, int index0, int index1)
swap
int tmp = array[index0];
array[index0] = array[index1];
array[index1] = tmp;
voidswap(int[] array, int x, int y)
Swaps the given indices x with y in the array.
int tmpIndex = array[x];
array[x] = array[y];
array[y] = tmpIndex;
voidswap(int[] inArray, int index1, int index2)
Swaps the positions index1 and index2 of inArray.
int temp = inArray[index1];
inArray[index1] = inArray[index2];
inArray[index2] = temp;
int[]swap(int[] integers, int positionX, int positionY)
swap
int temp = integers[positionX];
integers[positionX] = integers[positionY];
integers[positionY] = temp;
return integers;
voidswap(int[] list, int i, int j)
swap
int temp;
temp = list[i];
list[i] = list[j];
list[j] = temp;
voidswap(long[] a, int i, int change)
swap
long helper = a[i];
a[i] = a[change];
a[change] = helper;
voidswap(long[] keys, double[] values, int i, int j)
Swaps the keys and values at i with those at j
long keySwap = keys[i];
keys[i] = keys[j];
keys[j] = keySwap;
double swapValue = values[i];
values[i] = values[j];
values[j] = swapValue;