|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.decisiondeck.xmcda_oo.utils.matrix.ConstrainedMatrix<RowType,ColumnType>
RowType - the type of row objects used to reference positions.ColumnType - the type of column objects used to reference positions.public class ConstrainedMatrix<RowType,ColumnType>
A matrix associating double values to positions specified with a row and a column. The matrix is constrained, i.e.,
it uses a ConstrainedMatrix.FuzzyValidator to ensure that every value it contains is valid. This also guarantees that any value
given by this object is valid according to the ConstrainedMatrix.FuzzyValidator associated with this object.
TODO replace with a filtered Table, probably.
| Nested Class Summary | |
|---|---|
static class |
ConstrainedMatrix.AllValidator
|
static class |
ConstrainedMatrix.FuzzyValidator
|
static interface |
ConstrainedMatrix.Validator
An object able to discriminate between valid and invalid values. |
static class |
ConstrainedMatrix.ValidatorType
|
| Constructor Summary | |
|---|---|
ConstrainedMatrix(ConstrainedMatrix.ValidatorType validator)
|
|
ConstrainedMatrix(ConstrainedMatrix.ValidatorType actualValidator,
Set<ConstrainedMatrix.ValidatorType> watchedValidators)
|
|
| Method Summary | |
|---|---|
boolean |
approxEquals(IRdFloatMatrix<RowType,ColumnType> m2,
double imprecision)
Two matrix are "approximately equal" to a given degree of precision iff they contain values for the same mappings and the value they contain for each mapping are not more different than the given allowed imprecision. |
boolean |
equals(Object obj)
Two matrix are equal iff they are the same type and contain the same values at the same positions. |
Set<ColumnType> |
getColumns()
Returns a read-only view of the columns existing in this matrix. |
Double |
getEntry(RowType row,
ColumnType column)
Returns the value at the position composed by the given row and column, or null if there is none. |
Set<RowType> |
getRows()
Returns a view of the rows existing in this matrix. |
int |
getValueCount()
Gets the number of values in this matrix. |
int |
hashCode()
|
boolean |
isCompatible(ConstrainedMatrix.ValidatorType validator)
Checks whether the existing values in this matrix are compatible (i.e., satisfy) the given validator. |
boolean |
isComplete()
A matrix is complete iff it contains a value for every possible position (row, column) where row and column are rows and columns existing in this matrix (i.e. corresponding to at least one value). |
boolean |
isEmpty()
Checks whether this matrix contains no value. |
boolean |
isValid(double value)
|
boolean |
populateFrom(IRdFloatMatrix<RowType,ColumnType> matrix)
Copies all values from the given matrix in this matrix, provided they are valid (i.e. they all meet the constraint bound to this object). |
boolean |
put(RowType row,
ColumnType column,
double value)
Puts the given value at the position specified by the given row and column, provided that it is valid (according to the ConstrainedMatrix.FuzzyValidator bound to this object). |
Double |
remove(RowType row,
ColumnType column)
Removes the value in this matrix at the position specified by the given row and column. |
void |
setValidator(ConstrainedMatrix.ValidatorType validator)
Changes the validator this object uses to validate values put into it. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ConstrainedMatrix(ConstrainedMatrix.ValidatorType validator)
validator - not null.
public ConstrainedMatrix(ConstrainedMatrix.ValidatorType actualValidator,
Set<ConstrainedMatrix.ValidatorType> watchedValidators)
actualValidator - not null.watchedValidators - the validators to watch (optimization hint to allow for faster transition to one of the given
validators using setValidator(ValidatorType)). May be empty, but not null.| Method Detail |
|---|
public boolean approxEquals(IRdFloatMatrix<RowType,ColumnType> m2,
double imprecision)
IRdFloatMatrix
approxEquals in interface IRdFloatMatrix<RowType,ColumnType>m2 - the matrix to which to compare this object for approximate equality. If null, this method
returns false.imprecision - the maximal imprecision allowed.
true iff the given matrix is approximately equal to this one.public boolean equals(Object obj)
IRdFloatMatrixIRdFloatMatrix.approxEquals(IRdFloatMatrix, double) if this can be a problem.
equals in interface IRdFloatMatrix<RowType,ColumnType>equals in class Objectobj - the object to compare. May be null.
true iff the given object is equal to this matrix.Object.equals(java.lang.Object)public Set<ColumnType> getColumns()
IRdFloatMatrix
getColumns in interface IRdFloatMatrix<RowType,ColumnType>null. Empty iff this matrix is empty.
public Double getEntry(RowType row,
ColumnType column)
IRdFloatMatrixnull if there is none.
getEntry in interface IRdFloatMatrix<RowType,ColumnType>row - not null.column - not null.
null.public Set<RowType> getRows()
IRdFloatMatrix
getRows in interface IRdFloatMatrix<RowType,ColumnType>null. Empty iff this matrix is empty.public int getValueCount()
IRdFloatMatrixGets the number of values in this matrix.
Note that the word "size" is not used here because the size of the matrix could be understood as meaning its row count times its column count, which is the same as its value count only if it is complete.
getValueCount in interface IRdFloatMatrix<RowType,ColumnType>public int hashCode()
hashCode in class Objectpublic boolean isComplete()
IRdFloatMatrixA matrix is complete iff it contains a value for every possible position (row, column) where row and column are rows and columns existing in this matrix (i.e. corresponding to at least one value). An empty matrix is complete.
isComplete in interface IRdFloatMatrix<RowType,ColumnType>true iff this matrix is complete.public boolean isEmpty()
IRdFloatMatrix
isEmpty in interface IRdFloatMatrix<RowType,ColumnType>true iff the matrix contains no value.public boolean populateFrom(IRdFloatMatrix<RowType,ColumnType> matrix)
matrix - the matrix to copy the values from. Not null.
true iff all values have been copied from the matrix, or equivalently, true iff
this matrix has changed.
public boolean put(RowType row,
ColumnType column,
double value)
ConstrainedMatrix.FuzzyValidator bound to this object). If it is not, the value is not stored at the given
position and any object which was at that position (if any) remains there.
row - not null.column - not null.value - the value to store.
true iff the given value is valid, or, equivalently, true iff the given value
has been stored in this matrix.public boolean isValid(double value)
public Double remove(RowType row,
ColumnType column)
row - not null.column - not null.
null iff there was no value at
that position (and, hence, nothing was removed).public String toString()
toString in class Objectpublic void setValidator(ConstrainedMatrix.ValidatorType validator)
validator - not null.public boolean isCompatible(ConstrainedMatrix.ValidatorType validator)
ConstrainedMatrix(ValidatorType, Set)).
validator - not null.
true iff the values in this matrix are valid considering the given validator.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||