Java Array Swap swap(T[] ts, int i, int j)

Here you can find the source of swap(T[] ts, int i, int j)

Description

swap

License

Apache License

Declaration

static <T> void swap(T[] ts, int i, int j) 

Method Source Code

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

public class Main {
    static <T> void swap(T[] ts, int i, int j) {
        T tmp = ts[i];//  w  ww .j  a  v  a 2  s .  c  o m
        ts[i] = ts[j];
        ts[j] = tmp;
    }

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

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

Related

  1. swap(T[] array, int first_idx, int last_idx)
  2. swap(T[] array, int i, int len)
  3. swap(T[] array, int indexOne, int indexTwo)
  4. swap(T[] data, int a, int b)
  5. swap(T[] elements, int i, int j)
  6. swap2(double v[], int v2[], int i, int j)
  7. swap2Bytes(byte[] bytes, int offset)
  8. swap3(String[] a, int x, int y, int z)
  9. swapAll(final Object[] array)