Here you can find the source of swap(T[] arr, int i, int j)
Parameter | Description |
---|---|
arr | array |
i | index i |
j | index j |
private static <T> void swap(T[] arr, int i, int j)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w. j a v a 2 s .co m * Swap values in array * * @param arr array * @param i index i * @param j index j */ private static <T> void swap(T[] arr, int i, int j) { T t = arr[i]; arr[i] = arr[j]; arr[j] = t; } /** * swap ints at given positions in array * * @param arr array * @param i position * @param j position */ public static void swap(int[] arr, int i, int j) { arr[i] ^= arr[j]; arr[j] ^= arr[i]; arr[i] ^= arr[j]; } }