Java Matrix Swap swap2d(Object[][] array, int c1, int r1, int c2, int r2)

Here you can find the source of swap2d(Object[][] array, int c1, int r1, int c2, int r2)

Description

A method for swapping matrix cells in-place.

License

Open Source License

Parameter

Parameter Description
array The target array.
c1 The 1st swap column.
r1 The 1st swap row.
c2 The 2nd swap column.
r2 The 2nd swap row.

Declaration

public static void swap2d(Object[][] array, int c1, int r1, int c2, int r2) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  w w . j  a v  a 2 s . c  o  m*/
     * A method for swapping matrix cells in-place.
     * @param array The target array.
     * @param c1 The 1st swap column.
     * @param r1 The 1st swap row.
     * @param c2 The 2nd swap column.
     * @param r2 The 2nd swap row.
     */
    public static void swap2d(Object[][] array, int c1, int r1, int c2, int r2) {
        if (array == null) {
            throw new IllegalArgumentException("Array must not be null");
        }

        Object swap = array[c1][r1];
        array[c1][r1] = array[c2][r2];
        array[c2][r2] = swap;
    }
}

Related

  1. swap(double[][] noteOrder, final int i, final int j)
  2. swapColumns(byte[][] matrix, int a, int b)
  3. swapColumns(double[][] front, int colA, int colB)
  4. swapColumns(int i, int j, boolean[][] matrix)
  5. swapRows(double[][] a, int i, int j)