Java List Swap swap(final L list1, final L list2, final int index)

Here you can find the source of swap(final L list1, final L list2, final int index)

Description

swap

License

Apache License

Declaration

public static <E, L extends List<E>> void swap(final L list1, final L list2, final int index) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static <E, L extends List<E>> void swap(final L list1, final L list2, final int index) {
        final E temp = list1.get(index);
        list1.set(index, list2.get(index));
        list2.set(index, temp);/*w  w w  .ja  v  a 2s.  c  o m*/

    }

    public static <E, L extends List<E>> void swap(final L list1, final L list2, final int start, final int end) {
        for (int i = start; i < end; i++) {
            swap(list1, list2, i);
        }
    }
}

Related

  1. swap(final List list, final int index0, final int index1)
  2. swap(final List list, final int index1, final int index2)
  3. swap(final List list, int i1, int i2)
  4. swap(List list, int i, int j)