Android Array Reverse reverse(final short[] pArray)

Here you can find the source of reverse(final short[] pArray)

Description

reverse

Declaration

public static void reverse(final short[] pArray) 

Method Source Code

//package com.java2s;

public class Main {
    public static void reverse(final byte[] pArray) {
        if (pArray == null) {
            return;
        }/*w w  w. j  a  v a 2 s. com*/
        int i = 0;
        int j = pArray.length - 1;
        byte tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }

    public static void reverse(final short[] pArray) {
        if (pArray == null) {
            return;
        }
        int i = 0;
        int j = pArray.length - 1;
        short tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }

    public static void reverse(final int[] pArray) {
        if (pArray == null) {
            return;
        }
        int i = 0;
        int j = pArray.length - 1;
        int tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }

    public static void reverse(final long[] pArray) {
        if (pArray == null) {
            return;
        }
        int i = 0;
        int j = pArray.length - 1;
        long tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }

    public static void reverse(final float[] pArray) {
        if (pArray == null) {
            return;
        }
        int i = 0;
        int j = pArray.length - 1;
        float tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }

    public static void reverse(final double[] pArray) {
        if (pArray == null) {
            return;
        }
        int i = 0;
        int j = pArray.length - 1;
        double tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }

    public static void reverse(final Object[] pArray) {
        if (pArray == null) {
            return;
        }
        int i = 0;
        int j = pArray.length - 1;
        Object tmp;
        while (j > i) {
            tmp = pArray[j];
            pArray[j] = pArray[i];
            pArray[i] = tmp;
            j--;
            i++;
        }
    }
}

Related

  1. reverse(final int[] pArray)
  2. reverse(final int[] pArray)
  3. reverse(final long[] pArray)
  4. reverse(final long[] pArray)
  5. reverse(final short[] pArray)
  6. reverse(float[] array)
  7. reverse(int[] array)
  8. reverse(long[] array)
  9. reverse(short[] array)