Klasse Matrix<E>

java.lang.Object
ch.nolix.core.container.base.Container<E>
ch.nolix.core.container.matrix.Matrix<E>
Typparameter:
E - is the type of the elements of a Matrix.
Alle implementierten Schnittstellen:
IContainer<E>, IViewProviderContainer<E>, Mappable<E>, MultiSearchable<E>, ArrayMappable<E>, ICountingContainer<E>, IndexRequestable<E>, IStatisticalConainer<E>, IterableWithCopyableIterator<E>, SingleSearchable<E>, StoringRequestable<E>, StringMappable, IMatrix<E>, Clearable, EmptinessRequestable, MaterializationRequestable, Iterable<E>

public final class Matrix<E> extends Container<E> implements IMatrix<E>
A Matrix is a Container that stores its elements in rows and columns. A Matrix is clearable.
Version:
2016-08-01
Autor:
Silvan Wyss
  • Methodendetails

    • createEmpty

      public static <E2> Matrix<E2> createEmpty()
      Typparameter:
      E2 - is the type of the elements of the created Matrix.
      Gibt zurück:
      a new empty Matrix.
    • fromMatrix

      public static <E2> Matrix<E2> fromMatrix(IMatrix<E2> matrix)
      Typparameter:
      E2 - is the type of the elements of the given matrix.
      Parameter:
      matrix -
      Gibt zurück:
      a new Matrix with the size and elements of the given matrix.
    • addColumn

      public Matrix<E> addColumn(E element, E... elements)
      Adds a new column to the current Matrix with the given elements. The complexity of this implementation is O(m + n) if: -The current Matrix contains m elements. -n elements are given.
      Parameter:
      element -
      elements -
      Gibt zurück:
      the current Matrix.
      Löst aus:
      ArgumentIsNullException - if the given elements is null.
      ArgumentIsNullException - if one of the given elements is null.
      UnequalArgumentException - if the current Matrix is not empty and if not as many elements are given as the number of rows of the current Matrix.
    • addColumn

      public Matrix<E> addColumn(Iterable<E> elements)
      Adds a new column to the current Matrix with the given elements. The complexity of this implementation is O(m + n) if: -The current Matrix contains m elements. -n elements are given.
      Parameter:
      elements -
      Gibt zurück:
      the current Matrix.
      Löst aus:
      ArgumentIsNullException - if the given elements is null.
      ArgumentIsNullException - if one of the given elements is null.
      UnequalArgumentException - if the current Matrix is not empty and if not as many elements are given as the number of rows of the current Matrix.
    • addRow

      public Matrix<E> addRow(E element, E... elements)
      Adds a new row to the current Matrix with the given elements. The complexity of this implementation is O(m + n) if: -The current Matrix contains m rows. -n elements are given.
      Parameter:
      element -
      elements -
      Gibt zurück:
      the current Matrix.
      Löst aus:
      ArgumentIsNullException - if the given elements is null.
      ArgumentIsNullException - if one of the given elements is null.
      UnequalArgumentException - the current Matrix is not empty and if not as many elements are given as the number of columns of the current Matrix.
    • addRow

      public Matrix<E> addRow(Iterable<E> elements)
      Adds a new row to the current Matrix with the given elements. The complexity of this implementation is O(m + n) if: -The current Matrix contains m rows. -n elements are given.
      Parameter:
      elements -
      Gibt zurück:
      the current Matrix.
      Löst aus:
      ArgumentIsNullException - if the given elements is null.
      ArgumentIsNullException - if one of the given elements is null.
      UnequalArgumentException - the current Matrix is not empty and if not as many elements are given as the number of columns of the current Matrix.
    • clear

      public void clear()
      Removes all elements of the current Matrix. The complexity of this implementation is O(1).
      Angegeben von:
      clear in Schnittstelle Clearable
    • getColumn

      public MatrixColumn<E> getColumn(int columnIndex)
      Parameter:
      columnIndex -
      Gibt zurück:
      the column of the current Matrix with the given column index.
      Löst aus:
      NonPositiveArgumentException - if the given column index is not positive.
      BiggerArgumentException - if the given column index is bigger than the number of columns of the current Matrix.
    • getColumnCount

      public int getColumnCount()
      The time complexity of this implementation is O(1).
      Angegeben von:
      getColumnCount in Schnittstelle IMatrix<E>
      Gibt zurück:
      the number of columns of the current Matrix.
    • getColumnIndexOf

      public int getColumnIndexOf(int index)
      Parameter:
      index -
      Gibt zurück:
      the index of the column of the element of the current Matrix at the given index.
      Löst aus:
      NonPositiveArgumentException - if the given index is not positive.
      BiggerArgumentException - if the given index is bigger than the number of elements of the current Matrix.
    • getColumns

      public IContainer<MatrixColumn<E>> getColumns()
      Angegeben von:
      getColumns in Schnittstelle IMatrix<E>
      Gibt zurück:
      the columns of the current Matrix.
    • getCopy

      public Matrix<E> getCopy()
      The time complexity of this implementation is O(m * n) if: -This matrix contains m rows. -This matrix contains n columns.
      Gibt zurück:
      a new Matrix with the elements of the current Matrix.
    • getCount

      public int getCount()
      The time complexity of this implementation is O(1).
      Angegeben von:
      getCount in Schnittstelle ICountingContainer<E>
      Gibt zurück:
      the number of elements of the current Matrix.
    • getIndexOf

      public int getIndexOf(int rowIndex, int columnIndex)
      Parameter:
      rowIndex -
      columnIndex -
      Gibt zurück:
      the index of the element of the current Matrix at the given row index and column index.
      Löst aus:
      NonPositiveArgumentException - if the given row index is not positive.
      BiggerArgumentException - if the given row index is bigger than the number of rows of the current Matrix.
      NonPositiveArgumentException - if the given column index is not positive.
      BiggerArgumentException - if the given column index is bigger than the number of columns of the current Matrix.
    • getStoredAt1BasedIndex

      public E getStoredAt1BasedIndex(int param1BasedIndex)
      Angegeben von:
      getStoredAt1BasedIndex in Schnittstelle SingleSearchable<E>
      Parameter:
      param1BasedIndex -
      Gibt zurück:
      the element of the current Matrix at the given index .
      Löst aus:
      NonPositiveArgumentException - if the given index is not positive.
      BiggerArgumentException - if the given index is bigger than the number of elements of the current Matrix.
    • getStoredAt1BasedRowIndexAndColumnIndex

      public E getStoredAt1BasedRowIndexAndColumnIndex(int param1BasedRowIndex, int param1BasedColumnIndex)
      The time complexity of this implementation is O(1).
      Angegeben von:
      getStoredAt1BasedRowIndexAndColumnIndex in Schnittstelle IMatrix<E>
      Parameter:
      param1BasedRowIndex -
      param1BasedColumnIndex -
      Gibt zurück:
      the element of the current Matrix at the given row index and column index.
      Löst aus:
      NonPositiveArgumentException - if the given row index is not positive.
      BiggerArgumentException - if the given row index is bigger than the number of rows of the current Matrix.
      NonPositiveArgumentException - if the given column index is not positive.
      BiggerArgumentException - if the given column index is bigger than the number of columns of the current Matrix.
    • getRow

      public MatrixRow<E> getRow(int rowIndex)
      Parameter:
      rowIndex -
      Gibt zurück:
      the row of the current Matrix at the given row index.
      Löst aus:
      NonPositiveArgumentException - if the given row index is not positive.
      BiggerArgumentException - if the given row index is bigger than the number of rows of the current Matrix.
    • getRowIndexOf

      public int getRowIndexOf(int index)
      Parameter:
      index -
      Gibt zurück:
      the index of the row of the element of the current Matrix at the given index.
      Löst aus:
      NonPositiveArgumentException - if the given index is not positive.
      BiggerArgumentException - if the given index is bigger than the number of elements of the current Matrix.
    • getRows

      public IContainer<MatrixRow<E>> getRows()
      Angegeben von:
      getRows in Schnittstelle IMatrix<E>
      Gibt zurück:
      the rows of the current Matrix.
    • getRowCount

      public int getRowCount()
      The time complexity of this implementation is O(1).
      Angegeben von:
      getRowCount in Schnittstelle IMatrix<E>
      Gibt zurück:
      the number of rows of the current Matrix.
    • isMaterialized

      public boolean isMaterialized()
      Angegeben von:
      isMaterialized in Schnittstelle MaterializationRequestable
      Gibt zurück:
      true if the current MaterializationRequestable is materialized, false otherwise.
    • iterator

      public CopyableIterator<E> iterator()
      The time complexity of this implementation is O(1).
      Angegeben von:
      iterator in Schnittstelle Iterable<E>
      Angegeben von:
      iterator in Schnittstelle IterableWithCopyableIterator<E>
      Gibt zurück:
      a new iterator for the current Matrix.
    • setAt

      public void setAt(int index, E element)
      Sets the given element to the current Matrix at the given index. The complexity of this implementation is O(1).
      Parameter:
      index -
      element -
      Löst aus:
      NonPositiveArgumentException - if the given index is not positive.
      BiggerArgumentException - if the given index is bigger than the number of elements of the current Matrix.
      ArgumentIsNullException - if the given element is null.
    • setAt1BasedRowIndexAndColumnIndex

      public void setAt1BasedRowIndexAndColumnIndex(int param1BasedRowIndex, int param1BasedColumnIndex, E element)
      Sets the given element to the current Matrix to the row with the given row index and the column with the given column index. The time complexity of this implementation is O(1).
      Angegeben von:
      setAt1BasedRowIndexAndColumnIndex in Schnittstelle IMatrix<E>
      Parameter:
      param1BasedRowIndex -
      param1BasedColumnIndex -
      element -
      Löst aus:
      NonPositiveArgumentException - if the given row index is not positive.
      BiggerArgumentException - if the given row index is bigger than the number of rows of the current Matrix.
      NonPositiveArgumentException - if the given column index is not positive.
      BiggerArgumentException - if the given column index is bigger than the number of columns of the current Matrix.
      ArgumentIsNullException - if the given element is null.
    • toMatrix

      public <O> Matrix<O> toMatrix(Function<E,O> transformer)
      The time complexity of this implementation is O(n) if: -This matrix contains n elements. -The given transformer has a complexity of O(1).
      Typparameter:
      O - is the type of the elements the given transformer returns.
      Parameter:
      transformer -
      Gibt zurück:
      a new matrix with the elements the given transformer transforms of the elements of the current Matrix.
    • toLeftRotatedMatrix

      public Matrix<E> toLeftRotatedMatrix()
      The time complexity of this implementation is O(n) if the current Matrix contains n elements.
      Gibt zurück:
      a new left rotated Matrix of the current Matrix.
    • toOrderedList

      public <C extends Comparable<C>> IContainer<E> toOrderedList(Function<E,C> norm)
      Angegeben von:
      toOrderedList in Schnittstelle IContainer<E>
      Typparameter:
      C - is the type of the Comparables the given comparableMapper returns.
      Parameter:
      norm -
      Gibt zurück:
      a new IContainer with the elements of the current IContainer ordered from the smallest to the biggest element according to the Comparables the given comparableMapper maps from the elements of the current IContainer.
    • toRightRotatedMatrix

      public Matrix<E> toRightRotatedMatrix()
      The time complexity of this implementation is O(n) if the current Matrix contains n elements.
      Gibt zurück:
      a new right rotated Matrix of the current Matrix.
    • toString

      public String toString()
      The time complexity of this implementation is O(n) if: -The current Matrix contains n elements. -The toString method of the elements of the current Matrix has a complexity of O(1).
      Setzt außer Kraft:
      toString in Klasse Object
      Gibt zurück:
      a String representation of the current Matrix.
    • createEmptyMutableList

      protected <E2> ILinkedList<E2> createEmptyMutableList(Marker<E2> marker)
      Angegeben von:
      createEmptyMutableList in Klasse Container<E>
      Typparameter:
      E2 - is the type of the elements the created ILinkedList can contain.
      Parameter:
      marker -
      Gibt zurück:
      a new empty ILinkedList.