TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
Public Member Functions | Protected Attributes
Tinkercell::DataTable< T > Class Template Reference

DataTable is a 2D vector with row names and column names. More...

#include <DataTable.h>

List of all members.

Public Member Functions

virtual ~DataTable ()
 destructor
 DataTable ()
 constructor
 DataTable (int rows, int columns)
 constructor
virtual QString description () const
 get description of this table
virtual QString & description ()
 get or set description of this table
virtual QStringList columnNames () const
 get the column names
virtual bool hasRow (const QString &) const
 check is this table has a row with the given name
virtual bool hasColumn (const QString &) const
 check is this table has a column with the given name
virtual QStringList rowNames () const
 get the row names
virtual QString rowName (int i) const
 get the ith row name reference. can be used to change the row name
virtual QString columnName (int i) const
 get the ith column name. cannot be used to change the column name
virtual bool setRowName (int i, const QString &name)
 get the ith row name. cannot be used to change the row name
virtual bool setColumnName (int i, const QString &name)
 get the ith column name reference. can be used to change the column name
virtual void setColumnNames (const QStringList &names)
 set all the column names.
virtual void setRowNames (const QStringList &names)
 set all the row names.
virtual int rows () const
 get the number of rows
virtual int columns () const
 get the number of columns
virtual T & value (int i, int j=0)
 get the value at the ith row and jth column. can also be used to set the value
virtual T & operator() (int i, int j=0)
 get the value at the ith row and jth column. can also be used to set the value
virtual T operator() (int i, int j=0) const
 get the value at the ith row and jth column. can also be used to set the value
virtual T & value (const QString &r, const QString &c)
 get the value using row and column names. can also be used to set the value. Fast lookup using hashtables.
virtual T & operator() (const QString &r, const QString &c)
 get the value using row and column names. can also be used to set the value. Fast lookup using hashtables.
virtual T operator() (const QString &r, const QString &c) const
 get the value using row and column names. can also be used to set the value. Fast lookup using hashtables.
virtual T & value (const QString &r, int j=0)
 get the value using row name. can also be used to set the value. Fast lookup using hashtables.
virtual T & operator() (const QString &r, int j=0)
 get the value using row name and column index. can also be used to set the value. Fast lookup using hashtables.
virtual T operator() (const QString &r, int j=0) const
 get the value using row name and column index. can also be used to set the value. Fast lookup using hashtables.
virtual T & value (int i, const QString &c)
 get the value using column name. can also be used to set the value. Fast lookup using hashtables.
virtual T & operator() (int i, const QString &c)
 get the value using row name and column index. can also be used to set the value. Fast lookup using hashtables.
virtual T operator() (int i, const QString &c) const
 get the value using row index and column name. can also be used to set the value. Fast lookup using hashtables.
virtual bool operator== (const DataTable< T > &D)
 checks if the two data table's headers and contents are the same
virtual bool operator!= (const DataTable< T > &D)
 exactly opposite of operator ==
virtual T at (int i, int j=0) const
 get the value using row and column number. cannot also be used to set the value.
virtual T at (const QString &r, const QString &c) const
 get the value using row and column name. cannot also be used to set the value.
virtual T at (const QString &r, int j=0) const
 get the value using row name. cannot also be used to set the value.
virtual T at (int i, const QString &c) const
 get the value using column name. cannot also be used to set the value.
virtual void resize (int m, int n=1)
 set the size of the data table
virtual bool insertRow (int k, const QString &row)
 insert a new row at the given location with the given name. Insertion will fail if there is already a row with the same name
virtual bool insertColumn (int k, const QString &col)
 insert a new column at the given location with the given name. Insertion will fail if there is already a column with the same name
virtual bool removeRow (int k)
 remove an existing row at the given index.
virtual bool removeRow (const QString &name)
 remove an existing row with the given name.
virtual bool removeColumn (int k)
 remove an existing column at the given index.
virtual bool removeColumn (const QString &name)
 remove an existing col with the given name.
virtual void swapRows (int i1, int i2)
 swap two rows. Nothing will happen if the given numbers are outside the table
virtual void swapColumns (int j1, int j2)
 swap two columns. Nothing will happen if the given numbers are outside the table
virtual void swapRows (const QString &s1, const QString &s2)
 swap two rows using their name. Nothing will happen if the given numbers are outside the table
virtual void swapColumns (const QString &s1, const QString &s2)
 swap two columns using their name. Nothing will happen if the given numbers are outside the table
virtual DataTable< T > transpose () const
 get transpose of the table. complexity = n*m (use sparingly)

Protected Attributes

QVector< T > dataMatrix
 the values in the table
QVector< QString > colHeaders
 the column and row names
QVector< QString > rowHeaders
QHash< QString, int > colHash
 hash for quick lookup of row and columns by name
QHash< QString, int > rowHash
QString desc
 a description of this table (optional)

Detailed Description

template<typename T>
class Tinkercell::DataTable< T >

DataTable is a 2D vector with row names and column names.

Definition at line 43 of file DataTable.h.


Constructor & Destructor Documentation

template<typename T>
virtual Tinkercell::DataTable< T >::~DataTable ( ) [virtual]

destructor

template<typename T>
Tinkercell::DataTable< T >::DataTable ( )

constructor

template<typename T>
Tinkercell::DataTable< T >::DataTable ( int  rows,
int  columns 
)

constructor


Member Function Documentation

template<typename T>
virtual T Tinkercell::DataTable< T >::at ( int  i,
int  j = 0 
) const [virtual]

get the value using row and column number. cannot also be used to set the value.

Parameters:
introw number
intcolumn number (defaults to 0)
Returns:
T copy of value at given row and column. returns value at 0 if row and column are not in the table

Here is the caller graph for this function:

template<typename T>
virtual T Tinkercell::DataTable< T >::at ( int  i,
const QString &  c 
) const [virtual]

get the value using column name. cannot also be used to set the value.

Parameters:
introw number
intcolumn name
Returns:
T copy of value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T Tinkercell::DataTable< T >::at ( const QString &  r,
const QString &  c 
) const [virtual]

get the value using row and column name. cannot also be used to set the value.

Parameters:
QStringrow name
QStringcolumn name
Returns:
T copy of value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T Tinkercell::DataTable< T >::at ( const QString &  r,
int  j = 0 
) const [virtual]

get the value using row name. cannot also be used to set the value.

Parameters:
QStringrow name
intcolumn number (defaults to 0)
Returns:
T copy of value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual QString Tinkercell::DataTable< T >::columnName ( int  i) const [virtual]

get the ith column name. cannot be used to change the column name

Parameters:
intcol number
Returns:
QString copy of the ith column name

Here is the caller graph for this function:

template<typename T>
virtual QStringList Tinkercell::DataTable< T >::columnNames ( ) const [virtual]

get the column names

Returns:
QStringList column names (copy)

Here is the caller graph for this function:

template<typename T>
virtual int Tinkercell::DataTable< T >::columns ( ) const [virtual]

get the number of columns

Returns:
int number of columns

Here is the caller graph for this function:

template<typename T>
virtual QString& Tinkercell::DataTable< T >::description ( ) [virtual]

get or set description of this table

template<typename T>
virtual QString Tinkercell::DataTable< T >::description ( ) const [virtual]

get description of this table

template<typename T>
virtual bool Tinkercell::DataTable< T >::hasColumn ( const QString &  ) const [virtual]

check is this table has a column with the given name

Parameters:
QStringcolumn name
Returns:
bool true if the column with the name exists

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::hasRow ( const QString &  ) const [virtual]

check is this table has a row with the given name

Parameters:
QStringrow name
Returns:
bool true if the row with the name exists

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::insertColumn ( int  k,
const QString &  col 
) [virtual]

insert a new column at the given location with the given name. Insertion will fail if there is already a column with the same name

Parameters:
intcolumn number
QStringcolumn name
Returns:
Boolean false if failed, true if successful
template<typename T>
virtual bool Tinkercell::DataTable< T >::insertRow ( int  k,
const QString &  row 
) [virtual]

insert a new row at the given location with the given name. Insertion will fail if there is already a row with the same name

Parameters:
introw number
QStringrow name
Returns:
Boolean false if failed, true if successful

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::operator!= ( const DataTable< T > &  D) [virtual]

exactly opposite of operator ==

Parameters:
DataTable<T>
Returns:
bool
template<typename T>
virtual T& Tinkercell::DataTable< T >::operator() ( int  i,
int  j = 0 
) [virtual]

get the value at the ith row and jth column. can also be used to set the value

Parameters:
introw number
intcolumn number (defaults to 0)
Returns:
T reference to value at ith row and jth column. returns value at 0 if i or j are not inside the table
template<typename T>
virtual T Tinkercell::DataTable< T >::operator() ( int  i,
int  j = 0 
) const [virtual]

get the value at the ith row and jth column. can also be used to set the value

Parameters:
introw number
intcolumn number (defaults to 0)
Returns:
T value at ith row and jth column. returns value at 0 if i or j are not inside the table
template<typename T>
virtual T& Tinkercell::DataTable< T >::operator() ( const QString &  r,
const QString &  c 
) [virtual]

get the value using row and column names. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow name
QStringcolumn name
Returns:
T reference to value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T Tinkercell::DataTable< T >::operator() ( const QString &  r,
const QString &  c 
) const [virtual]

get the value using row and column names. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow name
QStringcolumn name
Returns:
T value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T& Tinkercell::DataTable< T >::operator() ( const QString &  r,
int  j = 0 
) [virtual]

get the value using row name and column index. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow name
QStringcolumn index
Returns:
T reference to value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T Tinkercell::DataTable< T >::operator() ( const QString &  r,
int  j = 0 
) const [virtual]

get the value using row name and column index. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow name
QStringcolumn index
Returns:
T value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T& Tinkercell::DataTable< T >::operator() ( int  i,
const QString &  c 
) [virtual]

get the value using row name and column index. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow index
QStringcolumn name
Returns:
T reference to value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T Tinkercell::DataTable< T >::operator() ( int  i,
const QString &  c 
) const [virtual]

get the value using row index and column name. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow index
QStringcolumn name
Returns:
T value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual bool Tinkercell::DataTable< T >::operator== ( const DataTable< T > &  D) [virtual]

checks if the two data table's headers and contents are the same

Parameters:
DataTable<T>
Returns:
bool
template<typename T>
virtual bool Tinkercell::DataTable< T >::removeColumn ( int  k) [virtual]

remove an existing column at the given index.

Parameters:
intcolumn number
Returns:
Boolean false if failed, true if successful

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::removeColumn ( const QString &  name) [virtual]

remove an existing col with the given name.

Parameters:
QStringrow name
Returns:
Boolean false if failed, true if successful
template<typename T>
virtual bool Tinkercell::DataTable< T >::removeRow ( int  k) [virtual]

remove an existing row at the given index.

Parameters:
introw number
Returns:
Boolean false if failed, true if successful

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::removeRow ( const QString &  name) [virtual]

remove an existing row with the given name.

Parameters:
QStringrow name
Returns:
Boolean false if failed, true if successful
template<typename T>
virtual void Tinkercell::DataTable< T >::resize ( int  m,
int  n = 1 
) [virtual]

set the size of the data table

Parameters:
introw count
intcolumn count (defaults to 1)
Returns:
void

Here is the caller graph for this function:

template<typename T>
virtual QString Tinkercell::DataTable< T >::rowName ( int  i) const [virtual]

get the ith row name reference. can be used to change the row name

Parameters:
intcol number
Returns:
QString copy to the ith row name

Here is the caller graph for this function:

template<typename T>
virtual QStringList Tinkercell::DataTable< T >::rowNames ( ) const [virtual]

get the row names

Returns:
QStringList row names (copy)

Here is the caller graph for this function:

template<typename T>
virtual int Tinkercell::DataTable< T >::rows ( ) const [virtual]

get the number of rows

Returns:
int number of rows

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::setColumnName ( int  i,
const QString &  name 
) [virtual]

get the ith column name reference. can be used to change the column name

Parameters:
intcol number
QStringname
Returns:
bool if the name already exists, returns false

Here is the caller graph for this function:

template<typename T>
virtual void Tinkercell::DataTable< T >::setColumnNames ( const QStringList &  names) [virtual]

set all the column names.

Parameters:
QStringListvector of strings
Returns:
void

Here is the caller graph for this function:

template<typename T>
virtual bool Tinkercell::DataTable< T >::setRowName ( int  i,
const QString &  name 
) [virtual]

get the ith row name. cannot be used to change the row name

Parameters:
introw number
QStringname
Returns:
bool if the name already exists, returns false

Here is the caller graph for this function:

template<typename T>
virtual void Tinkercell::DataTable< T >::setRowNames ( const QStringList &  names) [virtual]

set all the row names.

Parameters:
QStringListvector of strings
Returns:
void
template<typename T>
virtual void Tinkercell::DataTable< T >::swapColumns ( int  j1,
int  j2 
) [virtual]

swap two columns. Nothing will happen if the given numbers are outside the table

Parameters:
intfirst column number
intsecond column number
Returns:
void
template<typename T>
virtual void Tinkercell::DataTable< T >::swapColumns ( const QString &  s1,
const QString &  s2 
) [virtual]

swap two columns using their name. Nothing will happen if the given numbers are outside the table

Parameters:
intfirst column name
intsecond column name
Returns:
void
template<typename T>
virtual void Tinkercell::DataTable< T >::swapRows ( int  i1,
int  i2 
) [virtual]

swap two rows. Nothing will happen if the given numbers are outside the table

Parameters:
intfirst row number
intsecond row number
Returns:
void
template<typename T>
virtual void Tinkercell::DataTable< T >::swapRows ( const QString &  s1,
const QString &  s2 
) [virtual]

swap two rows using their name. Nothing will happen if the given numbers are outside the table

Parameters:
intfirst row name
intsecond row name
Returns:
void
template<typename T>
virtual DataTable<T> Tinkercell::DataTable< T >::transpose ( ) const [virtual]

get transpose of the table. complexity = n*m (use sparingly)

Returns:
DataTable<T> new data table
template<typename T>
virtual T& Tinkercell::DataTable< T >::value ( const QString &  r,
int  j = 0 
) [virtual]

get the value using row name. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow name
intcolumn number (defaults to 0)
Returns:
T reference to value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T& Tinkercell::DataTable< T >::value ( int  i,
int  j = 0 
) [virtual]

get the value at the ith row and jth column. can also be used to set the value

Parameters:
introw number
intcolumn number (defaults to 0)
Returns:
T reference to value at ith row and jth column. returns value at 0 if i or j are not inside the table

Here is the caller graph for this function:

template<typename T>
virtual T& Tinkercell::DataTable< T >::value ( const QString &  r,
const QString &  c 
) [virtual]

get the value using row and column names. can also be used to set the value. Fast lookup using hashtables.

Parameters:
QStringrow name
QStringcolumn name
Returns:
T reference to value at given row and column. returns value at 0 if row and column are not in the table
template<typename T>
virtual T& Tinkercell::DataTable< T >::value ( int  i,
const QString &  c 
) [virtual]

get the value using column name. can also be used to set the value. Fast lookup using hashtables.

Parameters:
introw number
QStringcolumn name
Returns:
T reference to value at given row and column. returns value at 0 if row and column are not in the table

Member Data Documentation

template<typename T>
QHash<QString,int> Tinkercell::DataTable< T >::colHash [protected]

hash for quick lookup of row and columns by name

Definition at line 51 of file DataTable.h.

template<typename T>
QVector<QString> Tinkercell::DataTable< T >::colHeaders [protected]

the column and row names

Definition at line 49 of file DataTable.h.

template<typename T>
QVector<T> Tinkercell::DataTable< T >::dataMatrix [protected]

the values in the table

Definition at line 47 of file DataTable.h.

template<typename T>
QString Tinkercell::DataTable< T >::desc [protected]

a description of this table (optional)

Definition at line 53 of file DataTable.h.

template<typename T>
QHash<QString,int> Tinkercell::DataTable< T >::rowHash [protected]

Definition at line 51 of file DataTable.h.

template<typename T>
QVector<QString> Tinkercell::DataTable< T >::rowHeaders [protected]

Definition at line 49 of file DataTable.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines