Java Matrix Flip flipOverX(T[][] arr)

Here you can find the source of flipOverX(T[][] arr)

Description

Flips 2D Array as if around a Horizontal Axis.

License

Open Source License

Parameter

Parameter Description
arr a parameter

Declaration

public static <T> void flipOverX(T[][] arr) 

Method Source Code

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

public class Main {
    /**//from ww  w .  j  a  v  a 2s  . co m
     * Flips 2D Array as if around a Horizontal Axis. Does NOT Preserve Original 2D Array.
     * @param arr
     */
    public static <T> void flipOverX(T[][] arr) {
        int z = arr.length - 1;

        for (int a = 0; a < z; a++) {
            T[] tmp = arr[a];
            arr[a] = arr[z];
            arr[z] = tmp;
        }
    }
}

Related

  1. flipInPlace(int[][] theArray)
  2. flipLeftToRight(int[][] theArray)
  3. flipLR(int[][] x)
  4. flipOverY(T[][] arr)