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(final Object[] array, final int i, final int j)
swap
final Object tmp = array[i];
array[i] = array[j];
array[j] = tmp;
voidswap(final Object[] array, int offset1, int offset2)
Swaps two elements in the given array.
if (array == null || array.length == 0) {
    return;
swap(array, offset1, offset2, 1);
voidswap(final Object[] array, int pos)
swap
swap(array, pos, pos + 1);
voidswap(final Object[] data, final int i, final int j)
Exchanges the elements at the two provided indices in the given array.
final Object tmp = data[i];
data[i] = data[j];
data[j] = tmp;
voidswap(final Object[] values, final int firstPosition, final int secondPosition)
swap
final Object temporary = values[firstPosition];
values[firstPosition] = values[secondPosition];
values[secondPosition] = temporary;
voidswap(final String a[], final int i, final int j)
Swaps two Strings.
String T;
T = a[i];
a[i] = a[j];
a[j] = T;
voidswap(final T[] arr, final int i, final int j)
Swaps two entries in a T array.
final T temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
voidswap(final T[] arr, final int i, final int j)
Swaps two entries in a T array.
final T temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
voidswap(int arr[], int i, int j)
Swap two positions.
int a = arr[i];
arr[i] = arr[j];
arr[j] = a;
voidswap(int array[], int first, int last)
swap the bytes of an integer array
int i, k;
for (i = first; i <= last; i++) {
    k = array[i];
    array[i] = ((k >>> 24) & 0xff) | ((k >>> 8) & 0xff00) | ((k & 0xff) << 24) | ((k & 0xff00) << 8);