Java Utililty Methods List Swap

List of utility methods to do List Swap

Description

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

Method

voidswap(final L list1, final L list2, final int index)
swap
final E temp = list1.get(index);
list1.set(index, list2.get(index));
list2.set(index, temp);
voidswap(final List list, final int index0, final int index1)
swap
Collections.swap(list, index0, index1);
voidswap(final List list, final int index1, final int index2)
Swaps two elements in a list.
if (index1 != index2) {
    final T value = list.get(index1);
    list.set(index1, list.get(index2));
    list.set(index2, value);
voidswap(final List list, int i1, int i2)
swap
if (i1 == i2) {
    return;
T temp = list.get(i1);
list.set(i1, list.get(i2));
list.set(i2, temp);
voidswap(List list, int i, int j)
Swaps the values in the list at the given positions
Object tmp = list.get(i);
list.set(i, list.get(j));
list.set(j, tmp);
voidswap(List list, Object object1, Object object2)
Swap object1 with object2 in the list.
int indexObject1 = list.indexOf(object1);
int indexObject2 = list.indexOf(object2);
list.set(indexObject2, object1);
list.set(indexObject1, object2);
voidswap(List a, int i, int j)
swap
final A tmp = a.get(i);
a.set(i, a.get(j));
a.set(j, tmp);
voidswap(List items, int index1_, int index2_)
swap
if (index1_ == index2_)
    return;
T item1 = items.get(index1_);
T item2 = items.get(index2_);
if (item1 != null)
    items.set(index2_, item1);
if (item2 != null)
    items.set(index1_, item2);
...
voidswap(List list, int i1, int i2)
Swaps two entries in a list.
T v1 = list.get(i1), v2 = list.get(i2);
list.set(i1, v2);
list.set(i2, v1);
Listswap(List list, int index1, int index2)
swap
list.set(index1, list.set(index2, list.get(index1)));
return list;