Class RangeMatrix<T>

java.lang.Object
dev.roanh.gmark.util.RangeMatrix<T>
Type Parameters:
T - The dta type stored in the matrix.
Direct Known Subclasses:
SelectivityGraph.DistanceMatrix

public class RangeMatrix<T> extends Object
A matrix implementation backed by a fixed size 2 dimensional array.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    The number of columns in this matrix.
    private T[][]
    The data stored in this matrix.
    private int
    The number of rows in this matrix.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RangeMatrix(int size)
    Constructs a new square range matrix with the given size.
    RangeMatrix(int rows, int cols)
    Constructs a new square range matrix with the given dimensions.
    RangeMatrix(int rows, int cols, Supplier<T> init)
    Constructs a new range matrix with the given dimensions and initialising every matrix element with the given supplier.
    RangeMatrix(int size, Supplier<T> init)
    Constructs a new square range matrix with the given size and initialising every matrix element with the given supplier.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int row, int col)
    Gets the element stored in the given matrix cell.
    get(int row, IDable col)
    Gets the element stored in the given matrix cell.
    get(IDable row, int col)
    Gets the element stored in the given matrix cell.
    get(IDable row, IDable col)
    Gets the element stored in the given matrix cell.
    int
    Gets the number of columns in this matrix.
    int
    Gets the number of rows in this matrix.
    void
    set(int row, int col, T value)
    Sets the element at the given matrix cell to the given value.
    void
    set(int row, IDable col, T value)
    Sets the element at the given matrix cell to the given value.
    void
    set(IDable row, int col, T value)
    Sets the element at the given matrix cell to the given value.
    void
    set(IDable row, IDable col, T value)
    Sets the element at the given matrix cell to the given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • data

      private T[][] data
      The data stored in this matrix.
    • rows

      private int rows
      The number of rows in this matrix.
    • cols

      private int cols
      The number of columns in this matrix.
  • Constructor Details

    • RangeMatrix

      public RangeMatrix(int size)
      Constructs a new square range matrix with the given size.
      Parameters:
      size - The size of the matrix.
    • RangeMatrix

      public RangeMatrix(int rows, int cols)
      Constructs a new square range matrix with the given dimensions.
      Parameters:
      rows - The number of rows in the matrix.
      cols - The number of columns in the matrix.
    • RangeMatrix

      public RangeMatrix(int size, Supplier<T> init)
      Constructs a new square range matrix with the given size and initialising every matrix element with the given supplier.
      Parameters:
      size - The size of the matrix.
      init - The supplier to initialise all matrix elements, possibly null.
    • RangeMatrix

      public RangeMatrix(int rows, int cols, Supplier<T> init)
      Constructs a new range matrix with the given dimensions and initialising every matrix element with the given supplier.
      Parameters:
      rows - The number of rows in the matrix.
      cols - The number of columns in the matrix.
      init - The supplier to initialise all matrix elements, possibly null.
  • Method Details

    • get

      public T get(IDable row, IDable col)
      Gets the element stored in the given matrix cell.
      Parameters:
      row - The row of the cell to get.
      col - The column of the cell to get.
      Returns:
      The element stored in the requested matrix cell.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
      See Also:
    • get

      public T get(int row, IDable col)
      Gets the element stored in the given matrix cell.
      Parameters:
      row - The row of the cell to get.
      col - The column of the cell to get.
      Returns:
      The element stored in the requested matrix cell.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
      See Also:
    • get

      public T get(IDable row, int col)
      Gets the element stored in the given matrix cell.
      Parameters:
      row - The row of the cell to get.
      col - The column of the cell to get.
      Returns:
      The element stored in the requested matrix cell.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
      See Also:
    • get

      public T get(int row, int col)
      Gets the element stored in the given matrix cell.
      Parameters:
      row - The row of the cell to get.
      col - The column of the cell to get.
      Returns:
      The element stored in the requested matrix cell.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
    • set

      public void set(IDable row, IDable col, T value)
      Sets the element at the given matrix cell to the given value.
      Parameters:
      row - The row of the cell to set.
      col - The column of the cell to set.
      value - The new data to store.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
    • set

      public void set(int row, IDable col, T value)
      Sets the element at the given matrix cell to the given value.
      Parameters:
      row - The row of the cell to set.
      col - The column of the cell to set.
      value - The new data to store.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
    • set

      public void set(IDable row, int col, T value)
      Sets the element at the given matrix cell to the given value.
      Parameters:
      row - The row of the cell to set.
      col - The column of the cell to set.
      value - The new data to store.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
    • set

      public void set(int row, int col, T value)
      Sets the element at the given matrix cell to the given value.
      Parameters:
      row - The row of the cell to set.
      col - The column of the cell to set.
      value - The new data to store.
      Throws:
      ArrayIndexOutOfBoundsException - When the given index is out of bounds.
    • getRowCount

      public int getRowCount()
      Gets the number of rows in this matrix.
      Returns:
      The number of rows in this matrix.
    • getColumnCount

      public int getColumnCount()
      Gets the number of columns in this matrix.
      Returns:
      The number of columns in this matrix.