baseCode.dataStructure.matrix
Class AbstractNamedMatrix

java.lang.Object
  extended bybaseCode.dataStructure.matrix.AbstractNamedMatrix
All Implemented Interfaces:
NamedMatrix
Direct Known Subclasses:
AbstractNamedDoubleMatrix, StringMatrix2DNamed

public abstract class AbstractNamedMatrix
extends java.lang.Object
implements NamedMatrix

Copyright (c) 2004 Columbia University

Version:
$Id: AbstractNamedMatrix.java,v 1.7 2005/03/18 02:53:38 pavlidis Exp $
Author:
pavlidis

Constructor Summary
AbstractNamedMatrix()
           
 
Method Summary
 void addColumnName(java.lang.String s)
          Add a column name when we don't care what the index will be.
 void addColumnName(java.lang.String s, int i)
          Add a column name associated with an index.
 void addRowName(java.lang.String s)
          Add a row name when we don't care what the index will be.
 void addRowName(java.lang.String s, int i)
          Add a row name associated with a row index.
abstract  int columns()
          Get the number of columns the matrix has.
 boolean containsColumnName(java.lang.String columnName)
           
 boolean containsRowName(java.lang.String rowName)
           
 int getColIndexByName(java.lang.String r)
          Get the index of a column by name.
 java.lang.String getColName(int i)
          Gte the column name for an index.
 java.util.List getColNames()
           
abstract  java.lang.Object[] getColObj(int i)
           
 int getRowIndexByName(java.lang.String s)
          Get the index of a row by name..
 java.lang.String getRowName(int i)
          Get the row name for an index
 java.util.Iterator getRowNameMapIterator()
           
 java.util.List getRowNames()
           
abstract  java.lang.Object[] getRowObj(int i)
          Get a row in the matrix as a generic Object[].
 boolean hasColNames()
          Check if this matrix has a valid set of column names.
 boolean hasRow(java.lang.String r)
           
 boolean hasRowNames()
           
abstract  boolean isMissing(int i, int j)
          Check if the value at a given index is missing.
 int numMissing()
          Return the number of missing values in the matrix.
abstract  int rows()
          Get the number of rows the matrix has
abstract  void set(int i, int j, java.lang.Object val)
          Set a value in the matrix.
 void setColumnNames(java.util.List v)
           
 void setRowNames(java.util.List v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNamedMatrix

public AbstractNamedMatrix()
Method Detail

addColumnName

public final void addColumnName(java.lang.String s)
Add a column name when we don't care what the index will be. The index will be set by the method. This is useful for when we need to set up a matrix before we know how many column or rows there are.

Parameters:
s -

addColumnName

public final void addColumnName(java.lang.String s,
                                int i)
Description copied from interface: NamedMatrix
Add a column name associated with an index.

Specified by:
addColumnName in interface NamedMatrix
Parameters:
s - String a column name
i - int the column index associated with this name

addRowName

public final void addRowName(java.lang.String s)
Add a row name when we don't care what the index will be. The index will be set by the method. This is useful for when we need to set up a matrix before we know how many column or rows there are.

Parameters:
s -

addRowName

public final void addRowName(java.lang.String s,
                             int i)
Description copied from interface: NamedMatrix
Add a row name associated with a row index.

Specified by:
addRowName in interface NamedMatrix
Parameters:
s - String
i - int

getRowIndexByName

public final int getRowIndexByName(java.lang.String s)
Description copied from interface: NamedMatrix
Get the index of a row by name..

Specified by:
getRowIndexByName in interface NamedMatrix
Parameters:
s - String
Returns:
int

getColIndexByName

public final int getColIndexByName(java.lang.String r)
Description copied from interface: NamedMatrix
Get the index of a column by name.

Specified by:
getColIndexByName in interface NamedMatrix
Parameters:
r - String
Returns:
int

getRowName

public final java.lang.String getRowName(int i)
Description copied from interface: NamedMatrix
Get the row name for an index

Specified by:
getRowName in interface NamedMatrix
Parameters:
i - int
Returns:
java.lang.String

getColName

public final java.lang.String getColName(int i)
Description copied from interface: NamedMatrix
Gte the column name for an index.

Specified by:
getColName in interface NamedMatrix
Parameters:
i - int
Returns:
java.lang.String

hasRowNames

public final boolean hasRowNames()
Specified by:
hasRowNames in interface NamedMatrix
Returns:
boolean

hasColNames

public final boolean hasColNames()
Description copied from interface: NamedMatrix
Check if this matrix has a valid set of column names.

Specified by:
hasColNames in interface NamedMatrix
Returns:
boolean

setRowNames

public final void setRowNames(java.util.List v)
Specified by:
setRowNames in interface NamedMatrix
Parameters:
v - List a vector of Strings.

setColumnNames

public final void setColumnNames(java.util.List v)
Specified by:
setColumnNames in interface NamedMatrix
Parameters:
v - List a vector of Strings.

getColNames

public final java.util.List getColNames()
Specified by:
getColNames in interface NamedMatrix
Returns:
List of Strings

getRowNames

public final java.util.List getRowNames()
Specified by:
getRowNames in interface NamedMatrix
Returns:
List of Strings

hasRow

public final boolean hasRow(java.lang.String r)
Specified by:
hasRow in interface NamedMatrix
Parameters:
r - String
Returns:
boolean

getRowNameMapIterator

public final java.util.Iterator getRowNameMapIterator()
Specified by:
getRowNameMapIterator in interface NamedMatrix
Returns:
java.util.Iterator

rows

public abstract int rows()
Description copied from interface: NamedMatrix
Get the number of rows the matrix has

Specified by:
rows in interface NamedMatrix
Returns:
int

columns

public abstract int columns()
Description copied from interface: NamedMatrix
Get the number of columns the matrix has.

Specified by:
columns in interface NamedMatrix
Returns:
int

set

public abstract void set(int i,
                         int j,
                         java.lang.Object val)
Description copied from interface: NamedMatrix
Set a value in the matrix.

Specified by:
set in interface NamedMatrix
Parameters:
i - int
j - int
val - Object

getRowObj

public abstract java.lang.Object[] getRowObj(int i)
Description copied from interface: NamedMatrix
Get a row in the matrix as a generic Object[]. This exists so NamedMatrices can be used more generically.

Specified by:
getRowObj in interface NamedMatrix
Parameters:
i - int row
Returns:
Object[]

getColObj

public abstract java.lang.Object[] getColObj(int i)
Specified by:
getColObj in interface NamedMatrix
Parameters:
i - int column
Returns:
Object[]

isMissing

public abstract boolean isMissing(int i,
                                  int j)
Description copied from interface: NamedMatrix
Check if the value at a given index is missing.

Specified by:
isMissing in interface NamedMatrix
Parameters:
i - row
j - column
Returns:
true if the value is missing, false otherwise.

containsRowName

public final boolean containsRowName(java.lang.String rowName)
Specified by:
containsRowName in interface NamedMatrix
Parameters:
rowName -
Returns:

containsColumnName

public final boolean containsColumnName(java.lang.String columnName)
Specified by:
containsColumnName in interface NamedMatrix
Parameters:
columnName -
Returns:

numMissing

public int numMissing()
Description copied from interface: NamedMatrix
Return the number of missing values in the matrix.

Specified by:
numMissing in interface NamedMatrix
Returns:


Copyright © 2003-2005 Columbia University. All Rights Reserved.