![]() |
TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
|
DataTable is a 2D vector with row names and column names. More...
#include <DataTable.h>
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) |
DataTable is a 2D vector with row names and column names.
Definition at line 43 of file DataTable.h.
virtual Tinkercell::DataTable< T >::~DataTable | ( | ) | [virtual] |
destructor
Tinkercell::DataTable< T >::DataTable | ( | ) |
constructor
Tinkercell::DataTable< T >::DataTable | ( | int | rows, |
int | columns | ||
) |
constructor
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.
int | row number |
int | column number (defaults to 0) |
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.
int | row number |
int | column name |
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.
QString | row name |
QString | column name |
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.
QString | row name |
int | column number (defaults to 0) |
virtual QString Tinkercell::DataTable< T >::columnName | ( | int | i | ) | const [virtual] |
get the ith column name. cannot be used to change the column name
int | col number |
virtual QStringList Tinkercell::DataTable< T >::columnNames | ( | ) | const [virtual] |
get the column names
virtual int Tinkercell::DataTable< T >::columns | ( | ) | const [virtual] |
get the number of columns
virtual QString& Tinkercell::DataTable< T >::description | ( | ) | [virtual] |
get or set description of this table
virtual QString Tinkercell::DataTable< T >::description | ( | ) | const [virtual] |
get description of this table
virtual bool Tinkercell::DataTable< T >::hasColumn | ( | const QString & | ) | const [virtual] |
check is this table has a column with the given name
QString | column name |
virtual bool Tinkercell::DataTable< T >::hasRow | ( | const QString & | ) | const [virtual] |
check is this table has a row with the given name
QString | row name |
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
int | column number |
QString | column name |
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
int | row number |
QString | row name |
virtual bool Tinkercell::DataTable< T >::operator!= | ( | const DataTable< T > & | D | ) | [virtual] |
exactly opposite of operator ==
DataTable<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
int | row number |
int | column number (defaults to 0) |
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
int | row number |
int | column number (defaults to 0) |
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.
QString | row name |
QString | column name |
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.
QString | row name |
QString | column name |
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.
QString | row name |
QString | column index |
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.
QString | row name |
QString | column index |
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.
QString | row index |
QString | column name |
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.
QString | row index |
QString | column name |
virtual bool Tinkercell::DataTable< T >::operator== | ( | const DataTable< T > & | D | ) | [virtual] |
checks if the two data table's headers and contents are the same
DataTable<T> |
virtual bool Tinkercell::DataTable< T >::removeColumn | ( | int | k | ) | [virtual] |
remove an existing column at the given index.
int | column number |
virtual bool Tinkercell::DataTable< T >::removeColumn | ( | const QString & | name | ) | [virtual] |
remove an existing col with the given name.
QString | row name |
virtual bool Tinkercell::DataTable< T >::removeRow | ( | int | k | ) | [virtual] |
remove an existing row at the given index.
int | row number |
virtual bool Tinkercell::DataTable< T >::removeRow | ( | const QString & | name | ) | [virtual] |
remove an existing row with the given name.
QString | row name |
virtual void Tinkercell::DataTable< T >::resize | ( | int | m, |
int | n = 1 |
||
) | [virtual] |
set the size of the data table
int | row count |
int | column count (defaults to 1) |
virtual QString Tinkercell::DataTable< T >::rowName | ( | int | i | ) | const [virtual] |
get the ith row name reference. can be used to change the row name
int | col number |
virtual QStringList Tinkercell::DataTable< T >::rowNames | ( | ) | const [virtual] |
get the row names
virtual int Tinkercell::DataTable< T >::rows | ( | ) | const [virtual] |
get the number of rows
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
int | col number |
QString | name |
virtual void Tinkercell::DataTable< T >::setColumnNames | ( | const QStringList & | names | ) | [virtual] |
set all the column names.
QStringList | vector of strings |
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
int | row number |
QString | name |
virtual void Tinkercell::DataTable< T >::setRowNames | ( | const QStringList & | names | ) | [virtual] |
set all the row names.
QStringList | vector of strings |
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
int | first column number |
int | second column number |
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
int | first column name |
int | second column name |
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
int | first row number |
int | second row number |
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
int | first row name |
int | second row name |
virtual DataTable<T> Tinkercell::DataTable< T >::transpose | ( | ) | const [virtual] |
get transpose of the table. complexity = n*m (use sparingly)
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.
QString | row name |
int | column number (defaults to 0) |
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
int | row number |
int | column number (defaults to 0) |
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.
QString | row name |
QString | column name |
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.
int | row number |
QString | column name |
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.
QVector<QString> Tinkercell::DataTable< T >::colHeaders [protected] |
the column and row names
Definition at line 49 of file DataTable.h.
QVector<T> Tinkercell::DataTable< T >::dataMatrix [protected] |
the values in the table
Definition at line 47 of file DataTable.h.
QString Tinkercell::DataTable< T >::desc [protected] |
a description of this table (optional)
Definition at line 53 of file DataTable.h.
QHash<QString,int> Tinkercell::DataTable< T >::rowHash [protected] |
Definition at line 51 of file DataTable.h.
QVector<QString> Tinkercell::DataTable< T >::rowHeaders [protected] |
Definition at line 49 of file DataTable.h.