|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
E
- the type of the elements.public interface Matrix<E>
Represents a two-dimensional matrix of objects.
Each element of a matrix can be referenced using
a two-dimensional index (r, c), where
r = 0,…, R - 1 is the row index, and
c = 0,…, C - 1 is the column index.
Methods are specified by this
interface to resize matrices
by adding or removing rows or columns.
A class implementing this interface might
implement the RandomAccess
interface.
This means that the get(int, int)
operation is efficient, and
that the returned views
also implement RandomAccess
.
Method Summary | |
---|---|
List<E> |
asList()
Returns a list view of this matrix. |
int |
columns()
Returns the number of columns in this matrix. |
boolean |
equals(Object o)
Compares the specified object with this matrix for equality. |
E |
get(int r,
int c)
Returns the element at index (r, c) of the matrix. |
int |
hashCode()
Returns the hash code value for the matrix. |
Iterator<E> |
iterator()
Constructs and returns an iterator traversing the elements of this matrix rowise. |
int |
rows()
Returns the number of rows in this matrix. |
E |
set(int r,
int c,
E value)
Sets the element at index (r, c) of the matrix to value, and returns the element previously at that position. |
void |
setColumns(int numColumns)
Sets the number of columns of this matrix to numColumns. |
void |
setRows(int numRows)
Sets the number of rows of this matrix to numRows. |
Object[][] |
to2DArray()
Returns a 2D array containing the elements of this matrix in the proper sequence. |
E[][] |
to2DArray(E[][] array)
Returns a 2D array containing the elements of this matrix in the proper sequence; the runtime type of the returned array is the same as the runtime type of the given array. |
List<E> |
viewColumn(int c)
Returns a list representing a view of column c of this matrix. |
Matrix<E> |
viewPart(int fromRow,
int fromColumn,
int toRow,
int toColumn)
Returns a view of a portion of this matrix containing rows fromRow (inclusive) to toRow (exclusive), and columns fromColumn (inclusive) to toColumn (exclusive). |
List<E> |
viewRow(int r)
Returns a list representing a view of row r of this matrix. |
Methods inherited from interface java.util.Collection |
---|
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray |
Method Detail |
---|
int rows()
int columns()
void setRows(int numRows)
rows()
, the
last rows of the matrix are
removed.
If numRows is greater than
rows()
, new
rows filled with null
references are added to the matrix.
This method is optional, and throws an
UnsupportedOperationException
if
not implemented.
numRows
- the new number of rows in the matrix.
IllegalArgumentException
- if numRows
is negative.
UnsupportedOperationException
- if this method is not supported.void setColumns(int numColumns)
columns()
, the
last columns of the matrix are
removed.
If numColumns is greater than
columns()
, new
columns filled with null
references are added to the matrix.
This method is optional, and throws an
UnsupportedOperationException
if
not implemented.
numColumns
- the new number of columns in the matrix.
IllegalArgumentException
- if numColumns
is negative.
UnsupportedOperationException
- if this method is not supported.E get(int r, int c)
r
- the row index.c
- the column index.
IndexOutOfBoundsException
- if r or
c are negative, if r is
greater than or equal to rows()
,
or if c is greater than or equal to columns()
.E set(int r, int c, E value)
UnsupportedOperationException
if
not implemented.
r
- the row index.c
- the column index.value
- the value of the element.
IndexOutOfBoundsException
- if r or
c are negative, if r is
greater than or equal to rows()
,
or if c is greater than or equal to columns()
.
UnsupportedOperationException
- if this
method is not implemented.Iterator<E> iterator()
iterator
in interface Collection<E>
iterator
in interface Iterable<E>
List<E> asList()
List.set(int, E)
to change elements.
The bahavior of the returned list
is undefined if the dimensions
of the backing matrix are changed.
This method is optional, and throws an
UnsupportedOperationException
if
not implemented.
UnsupportedOperationException
- if this
method is not implemented.List<E> viewRow(int r)
Object)
.
The bahavior of the returned list
is undefined if the dimensions
of the backing matrix are changed.
This method is optional, and throws an
UnsupportedOperationException
if
not implemented.
r
- the index of the row to get a view for.
IndexOutOfBoundsException
- if r
is negative or greater than or equal to rows()
.
UnsupportedOperationException
- if this
method is not implemented.List<E> viewColumn(int c)
Object)
.
The bahavior of the returned list
is undefined if the dimensions
of the backing matrix are changed.
This method is optional, and throws an
UnsupportedOperationException
if
not implemented.
c
- the index of the column to get a view for.
IndexOutOfBoundsException
- if c
is negative or greater than or equal to columns()
.
UnsupportedOperationException
- if this
method is not implemented.Matrix<E> viewPart(int fromRow, int fromColumn, int toRow, int toColumn)
UnsupportedOperationException
if
not implemented.
fromRow
- the starting row.fromColumn
- the ending row.toRow
- the starting column.toColumn
- the ending column.
IndexOutOfBoundsException
- if row
or column indices are out of bounds.
IllegalArgumentException
- if
fromRow is greater than
toRow, or
fromColumn is greater than
toColumn.
UnsupportedOperationException
- if this
method is not implemented.Object[][] to2DArray()
E[][] to2DArray(E[][] array)
array
- the array to use.
boolean equals(Object o)
equals
in interface Collection<E>
equals
in class Object
int hashCode()
asList()
.
This ensures that matrix1.equals (matrix2)
implies that matrix1.hashCode() == matrix2.hashCode()
for any two matrices,
matrix1 and matrix2,
as required by the general contract of
Object.hashCode.
hashCode
in interface Collection<E>
hashCode
in class Object
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |