List of utility methods to do Array Swap
void | swap(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; |
void | swap(int[] array, int i, int j) swap if (i == j) return; int old = array[i]; array[i] = array[j]; array[j] = old; |
void | swap(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];
|
void | swap(int[] array, int index0, int index1) swap int tmp = array[index0];
array[index0] = array[index1];
array[index1] = tmp;
|
void | swap(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;
|
void | swap(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; |
void | swap(int[] list, int i, int j) swap int temp;
temp = list[i];
list[i] = list[j];
list[j] = temp;
|
void | swap(long[] a, int i, int change) swap long helper = a[i];
a[i] = a[change];
a[change] = helper;
|
void | swap(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; |