Java Array Shift shift(int[][] array, boolean inverse)

Here you can find the source of shift(int[][] array, boolean inverse)

Description

shift

License

Apache License

Declaration

public static int[][] shift(int[][] array, boolean inverse) 

Method Source Code

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

public class Main {
    public static int[][] shift(int[][] array, boolean inverse) {
        int[][] result = new int[4][4];
        for (int i = 0; i < 4; i++)
            result[i] = shift(array[i], inverse ? i : -i);
        return result;
    }// w w w. j  a  v a2 s .  c om

    public static int[] shift(int[] array, int how) {
        if (how % array.length == 0)
            return array;
        if (how < -array.length)
            how %= array.length;
        int[] result = new int[array.length];
        for (int i = 0; i < array.length; i++)
            result[(i + array.length + how) % array.length] = array[i];
        return result;
    }
}

Related

  1. shift(final byte[] input, final int amount)
  2. shift(final double[] values, final double constant)
  3. shift(final Object[] array, int offset)
  4. Shift(int[] in, int amt, int spare)
  5. shift(int[] v, int n)
  6. shift(Object a[], int count)
  7. shift(String[] args, int count)
  8. shift(String[] array)
  9. shift(String[] in)