bpp-core3  3.0.0
bpp::Table< T > Class Template Reference

This class corresponds to a 'dataset', i.e. a table with data by rows and variable by columns. More...

#include <Bpp/Numeric/Table.h>

+ Inheritance diagram for bpp::Table< T >:
+ Collaboration diagram for bpp::Table< T >:

Public Member Functions

 Table (size_t nRow, size_t nCol)
 Build a new void Table object with nRow rows and nCol columns. More...
 
 Table (const std::vector< std::string > &colNames)
 Build a new void Table object with named columns. More...
 
 Table (const Table &table)
 
 Table (const std::vector< std::vector< T >> &vt)
 
Tableoperator= (const Table &table)
 
Tableoperator= (const std::vector< std::vector< T >> &vt)
 
Tableclone () const
 Create a copy of this object and send a pointer to it. More...
 
virtual ~Table ()
 
const std::vector< std::vector< T > > & getData () const
 
T & operator() (size_t rowIndex, size_t colIndex)
 
const T & operator() (size_t rowIndex, size_t colIndex) const
 
T & operator() (const std::string &rowName, const std::string &colName)
 
const T & operator() (const std::string &rowName, const std::string &colName) const
 
T & operator() (const std::string &rowName, size_t colIndex)
 
const T & operator() (const std::string &rowName, size_t colIndex) const
 
T & operator() (size_t rowIndex, const std::string &colName)
 
const T & operator() (size_t rowIndex, const std::string &colName) const
 
Work on columns.
size_t getNumberOfColumns () const
 
void setColumnNames (const std::vector< std::string > &colNames)
 Set the column names of this table. More...
 
const std::vector< std::string > & getColumnNames () const
 Get the column names of this table. More...
 
std::vector< std::string > & getColumnNames ()
 
std::string getColumnName (size_t index) const
 Get a given column name. More...
 
bool hasColumnNames () const
 
std::vector< T > & getColumn (size_t index)
 
const std::vector< T > & getColumn (size_t index) const
 
std::vector< T > & getColumn (const std::string &colName)
 
const std::vector< T > & getColumn (const std::string &colName) const
 
bool hasColumn (const std::string &colName) const
 Tell is a given column exists. More...
 
void deleteColumn (size_t index)
 Delete the given column. More...
 
void deleteColumns (size_t index, size_t len)
 Delete the given columns. More...
 
void deleteColumn (const std::string &colName)
 Delete the given column. More...
 
void addColumn (const std::vector< T > &newColumn, int pos=-1)
 Add a new column. More...
 
void addColumn (const std::string &colName, const std::vector< T > &newColumn, int pos=-1)
 Add a new column. More...
 
void addColumn (std::string &st, const std::string &sep="\, int pos=-1, int rowCol=-1)
 Add a new column. More...
 
void setColumn (const std::vector< T > &newColumn, size_t pos)
 Set a new column. More...
 
void setColumn (const std::string &colName, const std::vector< T > &newColumn, size_t pos)
 Set a new column. More...
 
Work on rows.
size_t getNumberOfRows () const
 
void setRowNames (const std::vector< std::string > &rowNames)
 Set the row names of this table. More...
 
std::vector< std::string > getRowNames ()
 Get the row names of this table. More...
 
const std::vector< std::string > & getRowNames () const
 
bool hasRow (const std::string &rowName) const
 Tell is a given row exists. More...
 
std::string getRowName (size_t index) const
 Get a given row name. More...
 
bool hasRowNames () const
 
std::vector< T > getRow (size_t index) const
 
std::vector< T > getRow (const std::string &rowName) const
 
void deleteRow (size_t index)
 Delete the given row. More...
 
void deleteRows (size_t index, size_t len)
 Delete the given rows. More...
 
void deleteRow (const std::string &rowName)
 Delete the given row. More...
 
void addRow (const std::vector< T > &newRow, int pos=-1)
 Add a new row. More...
 
void addRow (const std::string &rowName, const std::vector< T > &newRow, int pos=-1)
 Add a new row at a given position. More...
 
void addRow (std::string &st, const std::string &sep="\, int pos=-1, int rowCol=-1)
 Add a new row. More...
 

Static Public Member Functions

static std::unique_ptr< Table< T > > read (std::istream &in, bool byRow, const std::string &sep="\, bool header=true, int names=-1)
 Read a table form a stream in CSV-like. More...
 
static void write (const Table &data, std::ostream &out, bool byRow, const std::string &sep="\, bool alignHeaders=false)
 Write a Table object to stream in CSV-like format. More...
 
static void write (const Table &data, bpp::OutputStream &out, bool byRow, const std::string &sep="\, bool alignHeaders=false)
 

Protected Attributes

size_t nRow_
 
size_t nCol_
 
std::vector< std::vector< T > > data_
 
std::vector< std::string > rowNames_
 
std::vector< std::string > colNames_
 

Detailed Description

template<class T>
class bpp::Table< T >

This class corresponds to a 'dataset', i.e. a table with data by rows and variable by columns.

Data are stored as T objects, by column.

Definition at line 30 of file Table.h.

Constructor & Destructor Documentation

◆ Table() [1/4]

template<class T >
bpp::Table< T >::Table ( size_t  nRow,
size_t  nCol 
)
inline

Build a new void Table object with nRow rows and nCol columns.

Parameters
nRowThe number of rows of the Table.
nColThe number of columns of the Table.

Definition at line 47 of file Table.h.

Referenced by bpp::Table< T >::clone().

◆ Table() [2/4]

template<class T >
bpp::Table< T >::Table ( const std::vector< std::string > &  colNames)
inline

Build a new void Table object with named columns.

Parameters
colNamesThe names of the columns of the Table.
Exceptions
DuplicatedTableColumnNameExceptionIf colnames contains identical names.

Definition at line 67 of file Table.h.

References bpp::Table< T >::setColumnNames().

◆ Table() [3/4]

template<class T >
bpp::Table< T >::Table ( const Table< T > &  table)
inline

Definition at line 78 of file Table.h.

◆ Table() [4/4]

template<class T >
bpp::Table< T >::Table ( const std::vector< std::vector< T >> &  vt)
inline

Definition at line 86 of file Table.h.

◆ ~Table()

template<class T >
virtual bpp::Table< T >::~Table ( )
inlinevirtual

Definition at line 125 of file Table.h.

Member Function Documentation

◆ addColumn() [1/3]

template<class T >
void bpp::Table< T >::addColumn ( const std::vector< T > &  newColumn,
int  pos = -1 
)
inline

Add a new column.

Parameters
newColumnThe new column values.
posThe position optional (default : -1 for nb columns)
Exceptions
DimensionExceptionIf the number of values does not match the number of rows.
TableColumnNamesExceptionIf the table has row names.

Definition at line 554 of file Table.h.

References bpp::Table< T >::nRow_.

◆ addColumn() [2/3]

template<class T >
void bpp::Table< T >::addColumn ( const std::string &  colName,
const std::vector< T > &  newColumn,
int  pos = -1 
)
inline

Add a new column.

Parameters
colNameThe name of the column.
newColumnThe new column values.
posThe position optional (default : -1 for nb columns)
Exceptions
DimensionExceptionIf the number of values does not match the number of rows.
NoTableColumnNamesExceptionIf the table does not have row names.
DuplicatedTableColumnNameExceptionIf colName is already used.

Definition at line 580 of file Table.h.

References bpp::Table< T >::nCol_, and bpp::Table< T >::nRow_.

◆ addColumn() [3/3]

template<class T >
void bpp::Table< T >::addColumn ( std::string &  st,
const std::string &  sep = "\t",
int  pos = -1,
int  rowCol = -1 
)
inline

Add a new column.

Parameters
stthe input sting
sepThe row delimiter
posThe position optional (default : nb cols)
rowColthe indice of row where colnames are, starting from 0 (default -1 means no such column)

Definition at line 609 of file Table.h.

References bpp::StringTokenizer::getTokens().

◆ addRow() [1/3]

template<class T >
void bpp::Table< T >::addRow ( const std::vector< T > &  newRow,
int  pos = -1 
)
inline

Add a new row.

Parameters
newRowThe new row values.
posThe position optional (default : -1 for nb rows)

Definition at line 916 of file Table.h.

References bpp::Table< T >::nCol_, and bpp::Table< T >::nRow_.

◆ addRow() [2/3]

template<class T >
void bpp::Table< T >::addRow ( const std::string &  rowName,
const std::vector< T > &  newRow,
int  pos = -1 
)
inline

Add a new row at a given position.

Parameters
rowNameThe name of the row.
newRowThe new row values.
posThe position optional (default : -1 for nb rows)

Definition at line 942 of file Table.h.

References bpp::Table< T >::nCol_, and bpp::Table< T >::nRow_.

◆ addRow() [3/3]

template<class T >
void bpp::Table< T >::addRow ( std::string &  st,
const std::string &  sep = "\t",
int  pos = -1,
int  rowCol = -1 
)
inline

Add a new row.

Parameters
stthe input string
sepThe column delimiter
posThe position optional (default : nb rows)
rowColthe indice of column where rownames are, starting from 0 (default -1 means no such column)

Definition at line 973 of file Table.h.

References bpp::StringTokenizer::getTokens().

◆ clone()

template<class T >
Table* bpp::Table< T >::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::Clonable.

Definition at line 123 of file Table.h.

References bpp::Table< T >::Table().

◆ deleteColumn() [1/2]

template<class T >
void bpp::Table< T >::deleteColumn ( size_t  index)
inline

Delete the given column.

Parameters
indexThe index of the column.
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of columns.

Definition at line 490 of file Table.h.

◆ deleteColumn() [2/2]

template<class T >
void bpp::Table< T >::deleteColumn ( const std::string &  colName)
inline

Delete the given column.

Parameters
colNameThe name of the column.
Exceptions
NoTableColumnNamesExceptionIf no column names are associated to this table.
TableColumnNameNotFoundExceptionIf colName do not match existing column names.

Definition at line 528 of file Table.h.

References bpp::VectorTools::which().

◆ deleteColumns()

template<class T >
void bpp::Table< T >::deleteColumns ( size_t  index,
size_t  len 
)
inline

Delete the given columns.

Parameters
indexThe index of the first column
lenthe number of columns to delete
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of columns.

Definition at line 507 of file Table.h.

◆ deleteRow() [1/2]

template<class T >
void bpp::Table< T >::deleteRow ( size_t  index)
inline

Delete the given row.

Parameters
indexThe index of the row.
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of row.

Definition at line 845 of file Table.h.

References bpp::Table< T >::nCol_.

◆ deleteRow() [2/2]

template<class T >
void bpp::Table< T >::deleteRow ( const std::string &  rowName)
inline

Delete the given row.

Parameters
rowNameThe name of the row.
Exceptions
NoTableRowNamesExceptionIf no row names are associated to this table.
TableRowNameNotFoundExceptionIf rowName do not match existing column names.

Definition at line 888 of file Table.h.

References bpp::Table< T >::nCol_, and bpp::VectorTools::which().

◆ deleteRows()

template<class T >
void bpp::Table< T >::deleteRows ( size_t  index,
size_t  len 
)
inline

Delete the given rows.

Parameters
indexThe index of the first row.
lenthe number of rows to delete
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of row.

Definition at line 866 of file Table.h.

References bpp::Table< T >::nCol_.

◆ getColumn() [1/4]

template<class T >
std::vector<T>& bpp::Table< T >::getColumn ( size_t  index)
inline
Returns
The values in the given column.
Parameters
indexThe index of the column.
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of columns.

Definition at line 402 of file Table.h.

◆ getColumn() [2/4]

template<class T >
const std::vector<T>& bpp::Table< T >::getColumn ( size_t  index) const
inline
Returns
The values in the given column.
Parameters
indexThe index of the column.
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of columns.

Definition at line 414 of file Table.h.

◆ getColumn() [3/4]

template<class T >
std::vector<T>& bpp::Table< T >::getColumn ( const std::string &  colName)
inline
Returns
The values in the given column.
Parameters
colNameThe name of the column.
Exceptions
NoTableColumnNamesExceptionIf no column names are associated to this table.
TableColumnNameNotFoundExceptionIf colName do not match existing column names.

Definition at line 428 of file Table.h.

References bpp::VectorTools::which().

◆ getColumn() [4/4]

template<class T >
const std::vector<T>& bpp::Table< T >::getColumn ( const std::string &  colName) const
inline
Returns
The values in the given column.
Parameters
colNameThe name of the column.
Exceptions
NoTableColumnNamesExceptionIf no column names are associated to this table.
TableColumnNameNotFoundExceptionIf colName do not match existing column names.

Definition at line 449 of file Table.h.

References bpp::VectorTools::which().

◆ getColumnName()

template<class T >
std::string bpp::Table< T >::getColumnName ( size_t  index) const
inline

Get a given column name.

Parameters
indexThe index of the column.
Returns
The column name associated to the given column.
Exceptions
NoTableColumnNamesExceptionIf no column names are associated to this table.
IndexOutOfBoundsExceptionIf index is >= number of columns.

Definition at line 382 of file Table.h.

Referenced by bpp::Table< T >::write().

◆ getColumnNames() [1/2]

template<class T >
const std::vector<std::string>& bpp::Table< T >::getColumnNames ( ) const
inline

Get the column names of this table.

Returns
The column names of this table.
Exceptions
NoTableColumnNamesExceptionIf no column names are associated to this table.

Definition at line 360 of file Table.h.

References bpp::Table< T >::colNames_.

Referenced by bpp::Table< T >::write().

◆ getColumnNames() [2/2]

template<class T >
std::vector<std::string>& bpp::Table< T >::getColumnNames ( )
inline

Definition at line 367 of file Table.h.

References bpp::Table< T >::colNames_.

◆ getData()

template<class T >
const std::vector< std::vector<T> >& bpp::Table< T >::getData ( ) const
inline
Returns
The data.

Definition at line 132 of file Table.h.

References bpp::Table< T >::data_.

◆ getNumberOfColumns()

template<class T >
size_t bpp::Table< T >::getNumberOfColumns ( ) const
inline
Returns
The number of columns in this table.

Definition at line 334 of file Table.h.

References bpp::Table< T >::nCol_.

Referenced by bpp::Table< T >::write().

◆ getNumberOfRows()

template<class T >
size_t bpp::Table< T >::getNumberOfRows ( ) const
inline
Returns
The number of rows in this table.

Definition at line 707 of file Table.h.

References bpp::Table< T >::nRow_.

Referenced by bpp::Table< T >::write().

◆ getRow() [1/2]

template<class T >
std::vector<T> bpp::Table< T >::getRow ( size_t  index) const
inline
Returns
A vector which contains a copy in the given row.
Parameters
indexThe index of the row.
Exceptions
IndexOutOfBoundsExceptionIf index is >= number of rows.

Definition at line 799 of file Table.h.

References bpp::Table< T >::nCol_.

◆ getRow() [2/2]

template<class T >
std::vector<T> bpp::Table< T >::getRow ( const std::string &  rowName) const
inline
Returns
A vector which contains a copy in the given row.
Parameters
rowNameThe name of the row.
Exceptions
NoTableRowNamesExceptionIf no row names are associated to this table.
TableRowNameNotFoundExceptionIf rowName do not match existing row names.

Definition at line 818 of file Table.h.

References bpp::Table< T >::nCol_, and bpp::VectorTools::which().

◆ getRowName()

template<class T >
std::string bpp::Table< T >::getRowName ( size_t  index) const
inline

Get a given row name.

Parameters
indexThe index of the row.
Returns
The row name associated to the given row.
Exceptions
NoTableRowNamesExceptionIf no row names are associated to this table.
IndexOutOfBoundsExceptionIf index is >= number of rows.

Definition at line 779 of file Table.h.

Referenced by bpp::Table< T >::write().

◆ getRowNames() [1/2]

template<class T >
std::vector<std::string> bpp::Table< T >::getRowNames ( )
inline

Get the row names of this table.

Returns
The row names of this table.
Exceptions
NoTableRowNamesExceptionIf no row names are associated to this table.

Definition at line 737 of file Table.h.

References bpp::Table< T >::rowNames_.

Referenced by bpp::Table< T >::write().

◆ getRowNames() [2/2]

template<class T >
const std::vector<std::string>& bpp::Table< T >::getRowNames ( ) const
inline

Definition at line 744 of file Table.h.

References bpp::Table< T >::rowNames_.

◆ hasColumn()

template<class T >
bool bpp::Table< T >::hasColumn ( const std::string &  colName) const
inline

Tell is a given column exists.

Parameters
colNameThe name of the column to look for.
Returns
true if the column was found, false if not or if there are no column names.

Definition at line 471 of file Table.h.

◆ hasColumnNames()

template<class T >
bool bpp::Table< T >::hasColumnNames ( ) const
inline
Returns
true If column names are associated to this table.

Definition at line 395 of file Table.h.

Referenced by bpp::Table< T >::write().

◆ hasRow()

template<class T >
bool bpp::Table< T >::hasRow ( const std::string &  rowName) const
inline

Tell is a given row exists.

Parameters
rowNameThe name of the row to look for.
Returns
true if the row was found, false if not or if there are no row names.

Definition at line 758 of file Table.h.

◆ hasRowNames()

template<class T >
bool bpp::Table< T >::hasRowNames ( ) const
inline
Returns
true If row names are associated to this table.

Definition at line 792 of file Table.h.

Referenced by bpp::Table< T >::write().

◆ operator()() [1/8]

template<class T >
T& bpp::Table< T >::operator() ( size_t  rowIndex,
size_t  colIndex 
)
inline
Returns
The element at a given position.
Parameters
rowIndexRow number.
colIndexColumn number.
Exceptions
IndexOutOfBoundsExceptionIf one of the index is greater or equal to the corresponding number of columns/rows.

Definition at line 144 of file Table.h.

◆ operator()() [2/8]

template<class T >
const T& bpp::Table< T >::operator() ( size_t  rowIndex,
size_t  colIndex 
) const
inline
Returns
The element at a given position.
Parameters
rowIndexRow number.
colIndexColumn number.
Exceptions
IndexOutOfBoundsExceptionIf one of the index is greater or equal to the corresponding number of columns/rows.

Definition at line 159 of file Table.h.

◆ operator()() [3/8]

template<class T >
T& bpp::Table< T >::operator() ( const std::string &  rowName,
const std::string &  colName 
)
inline
Returns
The element at a given position.
Parameters
rowNameRow name.
colNameColumn name.
Exceptions
NoTableRowNamesExceptionIf the table does not have names associated to rows.
NoTableColumnNamesExceptionIf the table does not have names associated to columns.
TableNameNotFoundExceptionIf one of rowName or colName do not match existing names.

Definition at line 176 of file Table.h.

References bpp::ElementNotFoundException< T >::getElement(), and bpp::VectorTools::which().

◆ operator()() [4/8]

template<class T >
const T& bpp::Table< T >::operator() ( const std::string &  rowName,
const std::string &  colName 
) const
inline
Returns
The element at a given position.
Parameters
rowNameRow name.
colNameColumn name.
Exceptions
NoTableRowNamesExceptionIf the table does not have names associated to rows.
NoTableColumnNamesExceptionIf the table does not have names associated to columns.
TableNameNotFoundExceptionIf one of rowName or colName do not match existing names.

Definition at line 203 of file Table.h.

References bpp::ElementNotFoundException< T >::getElement(), and bpp::VectorTools::which().

◆ operator()() [5/8]

template<class T >
T& bpp::Table< T >::operator() ( const std::string &  rowName,
size_t  colIndex 
)
inline
Returns
The element at a given position.
Parameters
rowNameRow name.
colIndexColumn number.
Exceptions
NoTableRowNamesExceptionIf the table does not have names associated to rows.
IndexOutOfBoundsExceptionIf the index is greater or equal to the number of columns.
TableNameNotFoundExceptionIf rowName do not match existing names.

Definition at line 230 of file Table.h.

References bpp::ElementNotFoundException< T >::getElement(), and bpp::VectorTools::which().

◆ operator()() [6/8]

template<class T >
const T& bpp::Table< T >::operator() ( const std::string &  rowName,
size_t  colIndex 
) const
inline
Returns
The element at a given position.
Parameters
rowNameRow name.
colIndexColumn number.
Exceptions
NoTableRowNamesExceptionIf the table does not have names associated to rows.
IndexOutOfBoundsExceptionIf the index is greater or equal to the number of columns.
TableNameNotFoundExceptionIf rowName do not match existing names.

Definition at line 256 of file Table.h.

References bpp::ElementNotFoundException< T >::getElement(), and bpp::VectorTools::which().

◆ operator()() [7/8]

template<class T >
T& bpp::Table< T >::operator() ( size_t  rowIndex,
const std::string &  colName 
)
inline
Returns
The element at a given position.
Parameters
rowIndexRow number.
colNameColumn name.
Exceptions
IndexOutOfBoundsExceptionIf the index is greater or equal to the number of rows.
NoTableColumnNamesExceptionIf the table does not have names associated to columns.
TableNameNotFoundExceptionIf colName do not match existing names.

Definition at line 282 of file Table.h.

References bpp::ElementNotFoundException< T >::getElement(), and bpp::VectorTools::which().

◆ operator()() [8/8]

template<class T >
const T& bpp::Table< T >::operator() ( size_t  rowIndex,
const std::string &  colName 
) const
inline
Returns
The element at a given position.
Parameters
rowIndexRow number.
colNameColumn name.
Exceptions
IndexOutOfBoundsExceptionIf the index is greater or equal to the number of rows.
NoTableColumnNamesExceptionIf the table does not have names associated to columns.
TableNameNotFoundExceptionIf colName do not match existing names.

Definition at line 308 of file Table.h.

References bpp::ElementNotFoundException< T >::getElement(), and bpp::VectorTools::which().

◆ operator=() [1/2]

template<class T >
Table& bpp::Table< T >::operator= ( const Table< T > &  table)
inline

◆ operator=() [2/2]

template<class T >
Table& bpp::Table< T >::operator= ( const std::vector< std::vector< T >> &  vt)
inline

Definition at line 104 of file Table.h.

◆ read()

template<class T >
static std::unique_ptr<Table<T> > bpp::Table< T >::read ( std::istream &  in,
bool  byRow,
const std::string &  sep = "\t",
bool  header = true,
int  names = -1 
)
inlinestatic

Read a table form a stream in CSV-like.

By default, if the first line as one column less than the second one, the first line is taken as column names, and the first column as row names. Otherwise, no column names and no row names are specified, unless explicitely precised by the user. Note: if byRow=false, exchange row and column roles.

Parameters
inThe input stream.
byRowTell if the table is filled by rows
sepThe line delimiter.
headerTell if the first line must be used for names, otherwise use default.
namesUse a column as rowNames (or a row as columnNames). If positive, use the specified column to compute rownames, otherwise use default;
Returns
A pointer toward a new Table object.

Definition at line 1031 of file Table.h.

References bpp::FileTools::getNextLine(), bpp::StringTokenizer::getTokens(), and bpp::TextTools::isEmpty().

◆ setColumn() [1/2]

template<class T >
void bpp::Table< T >::setColumn ( const std::vector< T > &  newColumn,
size_t  pos 
)
inline

Set a new column.

Parameters
newColumnThe new column values.
posThe position
Exceptions
DimensionExceptionIf the number of values does not match the number of rows.
TableColumnNamesExceptionIf the table has row names.

Definition at line 656 of file Table.h.

References bpp::Table< T >::nRow_.

◆ setColumn() [2/2]

template<class T >
void bpp::Table< T >::setColumn ( const std::string &  colName,
const std::vector< T > &  newColumn,
size_t  pos 
)
inline

Set a new column.

Parameters
colNameThe name of the column.
newColumnThe new column values.
posThe position
Exceptions
DimensionExceptionIf the number of values does not match the number of rows.
NoTableColumnNamesExceptionIf the table does not have row names.
DuplicatedTableColumnNameExceptionIf colName is already used.

Definition at line 677 of file Table.h.

References bpp::Table< T >::nRow_.

◆ setColumnNames()

template<class T >
void bpp::Table< T >::setColumnNames ( const std::vector< std::string > &  colNames)
inline

Set the column names of this table.

Parameters
colNamesThe row names.
Exceptions
DimensionExceptionIf the number of names do not match the number of columns in the table.
DuplicatedTableColumnNameExceptionIf names are not unique.

Definition at line 343 of file Table.h.

References bpp::VectorTools::isUnique(), and bpp::Table< T >::nCol_.

Referenced by bpp::Table< T >::Table().

◆ setRowNames()

template<class T >
void bpp::Table< T >::setRowNames ( const std::vector< std::string > &  rowNames)
inline

Set the row names of this table.

Parameters
rowNamesThe row names.
Exceptions
DimensionExceptionIf the number of names do not match the number of rows in the table.
DuplicatedTableRowNameExceptionIf names are not unique.

Definition at line 716 of file Table.h.

References bpp::VectorTools::isUnique(), and bpp::Table< T >::nRow_.

◆ write() [1/2]

template<class T >
static void bpp::Table< T >::write ( const Table< T > &  data,
std::ostream &  out,
bool  byRow,
const std::string &  sep = "\t",
bool  alignHeaders = false 
)
inlinestatic

Write a Table object to stream in CSV-like format.

Parameters
dataThe table to write.
outThe output stream.
byRowTell if the table is written by rows.
sepThe column delimiter.
alignHeadersIf true, add a delimiter before the first column header if there is row names.

Definition at line 1092 of file Table.h.

References bpp::Table< T >::getColumnName(), bpp::Table< T >::getColumnNames(), bpp::Table< T >::getNumberOfColumns(), bpp::Table< T >::getNumberOfRows(), bpp::Table< T >::getRowName(), bpp::Table< T >::getRowNames(), bpp::Table< T >::hasColumnNames(), and bpp::Table< T >::hasRowNames().

◆ write() [2/2]

template<class T >
static void bpp::Table< T >::write ( const Table< T > &  data,
bpp::OutputStream out,
bool  byRow,
const std::string &  sep = "\t",
bool  alignHeaders = false 
)
inlinestatic

Member Data Documentation

◆ colNames_

template<class T >
std::vector<std::string> bpp::Table< T >::colNames_
protected

Definition at line 37 of file Table.h.

Referenced by bpp::Table< T >::getColumnNames(), and bpp::Table< T >::operator=().

◆ data_

template<class T >
std::vector< std::vector<T> > bpp::Table< T >::data_
protected

Definition at line 35 of file Table.h.

Referenced by bpp::Table< T >::getData(), and bpp::Table< T >::operator=().

◆ nCol_

◆ nRow_

◆ rowNames_

template<class T >
std::vector<std::string> bpp::Table< T >::rowNames_
protected

Definition at line 36 of file Table.h.

Referenced by bpp::Table< T >::getRowNames(), and bpp::Table< T >::operator=().


The documentation for this class was generated from the following file: