List of utility methods to do Array Swap
void | swap(short[] array, int indexA, int indexB) swap short t = array[indexA];
array[indexA] = array[indexB];
array[indexB] = t;
|
void | swap(String a[], int i, int j) Private method to swap two elements in the array String T; T = a[i]; a[i] = a[j]; a[j] = T; |
void | swap(T[] a, int i1, int i2) Swaps objects at specified index in array T temp = a[i1]; a[i1] = a[i2]; a[i2] = temp; |
void | swap(T[] a, int idx1, int idx2) Swaps two elements in an array. T tmp = a[idx1]; a[idx1] = a[idx2]; a[idx2] = tmp; |
void | swap(T[] arr, int a, int b) Swaps the elements at position a and b in the array arr .
if (a < 0 || a > arr.length || b < 0 || b > arr.length) throw new IllegalArgumentException("swap position out of bounds."); if (a != b) { T t = arr[a]; arr[a] = arr[b]; arr[b] = t; |
void | swap(T[] arr, int i, int j) Swap values in array T t = arr[i]; arr[i] = arr[j]; arr[j] = t; |
T[] | swap(T[] arr, int index1, int index2) Swaps two objects in an array. arr = arr.clone();
T temp = arr[index1];
arr[index1] = arr[index2];
arr[index2] = temp;
return arr;
|
void | swap(T[] arr, int pos1, int pos2) Exchanges two elements in the array. final T temp = arr[pos1];
arr[pos1] = arr[pos2];
arr[pos2] = temp;
|
void | swap(T[] array, int a, int b) Swaps the elements at the given positions in the array. T temp = array[a]; array[a] = array[b]; array[b] = temp; |
void | swap(T[] array, int first_idx, int last_idx) swap T tmp = array[first_idx]; array[first_idx] = array[last_idx]; array[last_idx] = tmp; |