Java Array Shift Shift(int[] in, int amt, int spare)

Here you can find the source of Shift(int[] in, int amt, int spare)

Description

Shift

License

Open Source License

Declaration

public static final void Shift(int[] in, int amt, int spare) 

Method Source Code


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

import java.util.*;

public class Main {
    public static final void Shift(int[] in, int amt, int spare) {
        if (amt > 0) {
            System.arraycopy(in, 0, in, amt, in.length - amt);
            Arrays.fill(in, 0, amt, spare);
        } else if (amt < 0) {
            System.arraycopy(in, -amt, in, 0, in.length + amt);
            Arrays.fill(in, in.length + amt, in.length, spare);
        }/*from   w w  w .  j  av a2 s .c  om*/
    }

    public static final void Shift(int[][] in, int amt, int spare) {
        for (int i = 0, s = in.length; i < s; i++)
            Shift(in[i], amt, spare);
    }
}

Related

  1. shift(double[] a, int shift, double insert)
  2. shift(double[] x, int N)
  3. shift(final byte[] input, final int amount)
  4. shift(final double[] values, final double constant)
  5. shift(final Object[] array, int offset)
  6. shift(int[] v, int n)
  7. shift(int[][] array, boolean inverse)
  8. shift(Object a[], int count)
  9. shift(String[] args, int count)