Class BitMatrix

java.lang.Object
fr.uga.pddl4j.util.BitMatrix
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SquareBitMatrix

public class BitMatrix extends Object implements Serializable
This class implements a bit matrix. This class introspection mechanism not more allowed with jre version superior to 1.8.
Revisions:
  • 31.03.2020: Add a deep copy constructor.
  • 26.06.2020: Change for bit vector intern representation.
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    The number of columns.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BitMatrix​(int size)
    Creates a new squared matrix of a specific size.
    BitMatrix​(int rows, int columns)
    Creates a new bit matrix with a specified number of rows and columns.
    BitMatrix​(BitMatrix other)
    Creates a deep copy from an other matrix.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRow​(int index, BitVector row)
    Adds a row at a specified index in the matrix.
    void
    addRow​(BitVector row)
    Adds a row at the end of the matrix.
    int
    Returns the cardinality of the matrix, i.e., the number of bits set to 1 in the matrix.
    void
    clear​(int row, int col)
    Sets the bit at a specified row and column position to false.
    int
    Returns the number of columns of the matrix.
    boolean
    equals​(Object obj)
    Returns true if this matrix is equals to an other object.
    boolean
    get​(int row, int col)
    Returns the value of the bit at a specific position in the matrix.
    getColumn​(int col)
    Returns the jth column of the matrix.
    getRow​(int row)
    Returns the ith row of the matrix.
    int
    Returns the hash code value of this matrix.
    void
    removeColumn​(int column)
    Remove a column of the matrix.
    void
    removeRow​(int row)
    Remove the jth row of the matrix.
    void
    resize​(int rows, int columns)
    Resizes the matrix.
    int
    Returns the number of rows of the matrix.
    void
    set​(int row, int col)
    Sets the bit at a specified row and column position to true.
    void
    set​(int row, int col, boolean value)
    Sets the bit at a specified row and column position to a specified value.
    Returns a string representation of the matrix based on bit representation.
    Returns a string representation of the matrix based on the bit vector representation.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • columns

      public int columns
      The number of columns.
  • Constructor Details

    • BitMatrix

      public BitMatrix(int rows, int columns)
      Creates a new bit matrix with a specified number of rows and columns.
      Parameters:
      rows - The number of rows of the matrix.
      columns - The number of column of the matrix.
    • BitMatrix

      public BitMatrix(BitMatrix other)
      Creates a deep copy from an other matrix.
      Parameters:
      other - The other matrix.
    • BitMatrix

      public BitMatrix(int size)
      Creates a new squared matrix of a specific size.
      Parameters:
      size - the size of the squared matrix.
  • Method Details

    • set

      public final void set(int row, int col)
      Sets the bit at a specified row and column position to true.
      Parameters:
      row - the row position.
      col - the column position.
    • set

      public final void set(int row, int col, boolean value)
      Sets the bit at a specified row and column position to a specified value.
      Parameters:
      row - the row position.
      col - the column position.
      value - the value to set.
    • clear

      public final void clear(int row, int col)
      Sets the bit at a specified row and column position to false.
      Parameters:
      row - the row position.
      col - the column position.
    • getRow

      public final BitVector getRow(int row)
      Returns the ith row of the matrix.
      Parameters:
      row - the index of the row.
      Returns:
      the ith row of the matrix.
    • removeRow

      public final void removeRow(int row)
      Remove the jth row of the matrix.
      Parameters:
      row - the index of the row to remove.
    • addRow

      public final void addRow(BitVector row)
      Adds a row at the end of the matrix.
      Parameters:
      row - the row to add.
    • addRow

      public void addRow(int index, BitVector row)
      Adds a row at a specified index in the matrix.
      Parameters:
      index - the index where the row must be added.
      row - the row to add.
    • getColumn

      public final BitVector getColumn(int col)
      Returns the jth column of the matrix.
      Parameters:
      col - the index of the column.
      Returns:
      the jth column of the matrix.
    • removeColumn

      public final void removeColumn(int column)
      Remove a column of the matrix.
      Parameters:
      column - the index of the column to remove.
    • get

      public final boolean get(int row, int col)
      Returns the value of the bit at a specific position in the matrix.
      Parameters:
      row - The row of the bit.
      col - The column of the bit.
      Returns:
      the value of the bit at a specific position in the matrix.
    • cardinality

      public final int cardinality()
      Returns the cardinality of the matrix, i.e., the number of bits set to 1 in the matrix.
      Returns:
      Returns the cardinality of the matrix.
    • columns

      public final int columns()
      Returns the number of columns of the matrix.
      Returns:
      the number of columns of the matrix.
    • rows

      public final int rows()
      Returns the number of rows of the matrix.
      Returns:
      the number of rows of the matrix.
    • resize

      public final void resize(int rows, int columns)
      Resizes the matrix.
      Parameters:
      rows - the new number of rows.
      columns - the new number of columns.
    • equals

      public boolean equals(Object obj)
      Returns true if this matrix is equals to an other object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compared.
      Returns:
      true if this matrix is equals to an other object; false otherwise.
      See Also:
      Object.equals(java.lang.Object)
    • hashCode

      public int hashCode()
      Returns the hash code value of this matrix.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value of this matrix.
      See Also:
      Object.hashCode()
    • toString

      public String toString()
      Returns a string representation of the matrix based on the bit vector representation.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the matrix.
      See Also:
      BitSet.toString()
    • toBitString

      public String toBitString()
      Returns a string representation of the matrix based on bit representation.
      Returns:
      a string representation of the matrix.