Java Array Swap swap(final Object[] array, final int i, final int j)

Here you can find the source of swap(final Object[] array, final int i, final int j)

Description

swap

License

Open Source License

Declaration

public static void swap(final Object[] array, final int i, final int j) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void swap(final Object[] array, final int i, final int j) {
        final Object tmp = array[i];
        array[i] = array[j];/*from w  w  w  . jav a2 s.  co  m*/
        array[j] = tmp;
    }

    public static void swap(final boolean[] array, final int i, final int j) {
        final boolean tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final byte[] array, final int i, final int j) {
        final byte tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final char[] array, final int i, final int j) {
        final char tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final short[] array, final int i, final int j) {
        final short tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final int[] array, final int i, final int j) {
        final int tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final long[] array, final int i, final int j) {
        final long tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final float[] array, final int i, final int j) {
        final float tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

    public static void swap(final double[] array, final int i, final int j) {
        final double tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }
}

Related

  1. swap(final float[] pVertices, final int pVertexStride, final int pVertexIndexA, final int pVertexIndexB)
  2. swap(final int a[], final int i, final int j)
  3. swap(final int[] array, final int i, final int j)
  4. swap(final int[] array, final int indexA, final int indexB)
  5. swap(final int[] array, final int pos1, final int pos2)
  6. swap(final Object[] array, int offset1, int offset2)
  7. swap(final Object[] array, int pos)
  8. swap(final Object[] data, final int i, final int j)
  9. swap(final Object[] values, final int firstPosition, final int secondPosition)