Java Array Shift shiftRight(T[] array)

Here you can find the source of shiftRight(T[] array)

Description

shift Right

License

BSD License

Declaration

public static <T> void shiftRight(T[] array) 

Method Source Code

//package com.java2s;
/**/*from   w  w  w. j  a  v a  2 s.  c  om*/
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author Jay Codec
 * 
 */

public class Main {
    public static <T> void shiftRight(T[] array) {
        for (int i = 1; i < array.length; i++) {
            array[i] = array[i - 1];
        }
        array[0] = null;
    }

    public static <T> void shiftRight(T[] array, int from, int to) {
        for (int i = to - 1; i > from; i--) {
            array[i] = array[i - 1];
        }
        array[from] = null;
    }

    public static <T> void shiftRight(T[] array, int to) {
        shiftRight(array, 0, to);
    }
}

Related

  1. shiftRight(byte[] block)
  2. shiftRight(byte[] x)
  3. shiftRight(int[] result, int[] vec, int shift)
  4. shiftRight(int[] x)
  5. shiftRight(Object[] array, final int amount)
  6. shiftRight2(T[] array, int to)
  7. shiftRightN(int[] block, int n)
  8. shiftRightN(int[] block, int n)
  9. shiftRightN(int[] x, int n)