|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.datatype.SparseBooleanMatrix
public class SparseBooleanMatrix
Sparse representation of a boolean matrix, using HashSets. Fast row-wise access is possible. Indexes are zero-based. TODO Implement the classes below. If you need a more memory-efficient data structure, try SparseBooleanMatrixBinarySearch or SparseBooleanMatrixStatic.
Constructor Summary | |
---|---|
SparseBooleanMatrix()
Default constructor |
Method Summary | |
---|---|
IMatrix<java.lang.Boolean> |
createMatrix(int x,
int y)
Create a matrix with a given number of rows and columns. |
IntSet |
get(int x)
Get a row. |
java.lang.Boolean |
get(int x,
int y)
Get the value at (i,j) |
IntList |
getEntriesByColumn(int column_id)
Takes O(N) worst-case time, where N is the number of rows, if the internal hash table can be queried in constant time. |
IntList |
getEntriesByRow(int row_id)
Get all true entries (column IDs) of a row. |
void |
grow(int num_rows,
int num_cols)
Grows the matrix to the requested size, if necessary. |
boolean |
isSymmetric()
True if the matrix is symmetric, false otherwise. |
IntCollection |
nonEmptyColumnIDs()
Get the IDs of the non-empty columns in the matrix (the ones that contain at least one true entry) |
IntCollection |
nonEmptyRowIDs()
The IDs of the non-empty rows in the matrix (the ones that contain at least one true entry) |
java.util.HashMap<java.lang.Integer,IntSet> |
nonEmptyRows()
The non-empty rows of the matrix (the ones that contain at least one true entry), with their IDs. |
int |
numberOfColumns()
Get the number of columns of the matrix. |
int |
numberOfEntries()
Returns the number of (true) entries. |
int |
numberOfRows()
Get the number of rows of the matrix. |
int |
numEntriesByColumn(int column_id)
Get all the number of entries in a column. |
int |
numEntriesByRow(int row_id)
Get all the number of entries in a row. |
int |
overlap(IBooleanMatrix s)
Get the overlap of two matrices, i.e. |
void |
set(int x,
int y,
java.lang.Boolean value)
Set the value at (i,j) |
IMatrix<java.lang.Boolean> |
transpose()
Get the transpose of the matrix, i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SparseBooleanMatrix()
Method Detail |
---|
public java.lang.Boolean get(int x, int y)
IMatrix
get
in interface IMatrix<java.lang.Boolean>
x
- the row IDy
- the column ID
public void set(int x, int y, java.lang.Boolean value)
IMatrix
set
in interface IMatrix<java.lang.Boolean>
x
- the row IDy
- the column IDvalue
- the valuepublic IntSet get(int x)
get
in interface IBooleanMatrix
x
- the row ID
public boolean isSymmetric()
IMatrix
isSymmetric
in interface IMatrix<java.lang.Boolean>
public IMatrix<java.lang.Boolean> createMatrix(int x, int y)
IMatrix
createMatrix
in interface IMatrix<java.lang.Boolean>
x
- the number of rowsy
- the number of columns
public IntList getEntriesByRow(int row_id)
IBooleanMatrix
getEntriesByRow
in interface IBooleanMatrix
row_id
- the row ID
public int numEntriesByRow(int row_id)
IBooleanMatrix
numEntriesByRow
in interface IBooleanMatrix
row_id
- the row ID
public IntList getEntriesByColumn(int column_id)
getEntriesByColumn
in interface IBooleanMatrix
column_id
- the column ID
public int numEntriesByColumn(int column_id)
IBooleanMatrix
numEntriesByColumn
in interface IBooleanMatrix
column_id
- the column ID
public java.util.HashMap<java.lang.Integer,IntSet> nonEmptyRows()
public IntCollection nonEmptyRowIDs()
nonEmptyRowIDs
in interface IBooleanMatrix
public IntCollection nonEmptyColumnIDs()
nonEmptyColumnIDs
in interface IBooleanMatrix
public int numberOfRows()
IMatrix
numberOfRows
in interface IMatrix<java.lang.Boolean>
public int numberOfColumns()
IMatrix
numberOfColumns
in interface IMatrix<java.lang.Boolean>
public int numberOfEntries()
numberOfEntries
in interface IBooleanMatrix
public void grow(int num_rows, int num_cols)
IMatrix
grow
in interface IMatrix<java.lang.Boolean>
num_rows
- the minimum number of rowsnum_cols
- the minimum number of columnspublic IMatrix<java.lang.Boolean> transpose()
transpose
in interface IMatrix<java.lang.Boolean>
public int overlap(IBooleanMatrix s)
IBooleanMatrix
overlap
in interface IBooleanMatrix
s
- the
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |