Here you can find the source of swap(boolean[] array, int i1, int i2)
Parameter | Description |
---|---|
array | te vector |
i1 | the index of the first element to be swapped |
i2 | the index of the second element to be swapped |
public static void swap(boolean[] array, int i1, int i2)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j ava 2 s . co m * Swaps two elements of a vector * @param array te vector * @param i1 the index of the first element to be swapped * @param i2 the index of the second element to be swapped */ public static void swap(int[] array, int i1, int i2) { int temp = array[i1]; array[i1] = array[i2]; array[i2] = temp; } /** * Swaps two elements of a vector * @param array te vector * @param i1 the index of the first element to be swapped * @param i2 the index of the second element to be swapped */ public static void swap(boolean[] array, int i1, int i2) { boolean temp = array[i1]; array[i1] = array[i2]; array[i2] = temp; } /** * Swaps two elements of a vector * @param array te vector * @param i1 the index of the first element to be swapped * @param i2 the index of the second element to be swapped */ public static void swap(double[] array, int i1, int i2) { double temp = array[i1]; array[i1] = array[i2]; array[i2] = temp; } /** * Swaps two elements of a vector * @param array te vector * @param i1 the index of the first element to be swapped * @param i2 the index of the second element to be swapped */ public static void swap(char[] array, int i1, int i2) { char temp = array[i1]; array[i1] = array[i2]; array[i2] = temp; } }