Class Matrix<T>

  • Type Parameters:
    T - Data type of Entry payload.

    public class Matrix<T>
    extends Object
    An expandable and variable width matrix backed by ArrayLists.

    Every cell in the Matrix is backed by an Entry<T>.

    • Constructor Detail

      • Matrix

        public Matrix()
    • Method Detail

      • get

        public List<List<Matrix.Entry<T>>> get()
        Returns the datastore. I.e. a List (rows) of Lists (columns) of entries.
        Returns:
        the complete matrix.
      • get

        public List<Matrix.Entry<T>> get​(int rowPos)
        Returns the specified row.
        Parameters:
        rowPos - row index.
        Returns:
        a row (List of entries in each column).
      • get

        public Matrix.Entry<T> get​(int rowPos,
                                   int colPos)
        Fetches an Entry at the specified row and column position.
        Parameters:
        rowPos - row index
        colPos - column index
        Returns:
        Entry
      • getMaxRowWidth

        public int getMaxRowWidth()
        Returns:
        the number of items in the row with largest size
      • isEmpty

        public boolean isEmpty()
        Returns:
        if matrix is empty
      • getCellDataAsSet

        public Set<T> getCellDataAsSet()
        Fetches all cell data and returns as Set
        Returns:
        Set of all cell data in the built Matrix. No null included in Set.
      • getNumberOfCells

        public long getNumberOfCells()
        Returns:
        the total number of cell in the matrix including null cells
      • put

        public void put​(int rowPos,
                        int colPos,
                        @Nullable
                        Matrix.Entry<T> value)
        Puts an Entry at the specified row and column position.

        Rows and columns will expand to match the specified coordinates. Empty cells will be filled with nulls.

        Parameters:
        rowPos - row index
        colPos - col index
        value - Entry to store