NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
CNcbiTable< TValue, TRow, TColumn > Class Template Reference

Search Toolkit Book for CNcbiTable

Template class to create a table with custom row-column access. More...

#include <util/ncbi_table.hpp>

+ Collaboration diagram for CNcbiTable< TValue, TRow, TColumn >:

Public Types

typedef map< TRow, unsigned intTRowMap
 
typedef map< TColumn, unsigned intTColumnMap
 
typedef TValue TValueType
 
typedef vector< TValue > TRowType
 

Public Member Functions

 CNcbiTable ()
 
 CNcbiTable (unsigned int rows, unsigned int cols)
 Construction. More...
 
 CNcbiTable (const CNcbiTable &table)
 
CNcbiTableoperator= (const CNcbiTable &table)
 
 ~CNcbiTable ()
 
unsigned int Rows () const
 Number of rows. More...
 
unsigned int Cols () const
 Number of column. More...
 
void AddColumn (const TColumn &col)
 Add column to the table, column recieves name "col". More...
 
void AddRow (const TRow &row)
 Add row to the table, column recieves name "row". More...
 
void AssociateRow (const TRow &row, unsigned int row_idx)
 Set up row name. More...
 
void AssociateColumn (const TColumn &col, unsigned int col_idx)
 Set up column name. More...
 
void Resize (unsigned int rows, unsigned int cols)
 Change table size. More...
 
void Resize (unsigned int rows, unsigned int cols, const TValue &v)
 Change table size, new table elements initialized with value. More...
 
const TRowTypeGetRow (const TRow &row) const
 Get table row. More...
 
const TRowTypeGetRowVector (unsigned int row_idx) const
 Get table row by row index. More...
 
TRowTypeGetRowVector (unsigned int row_idx)
 Get table row by row index. More...
 
const TValueTypeGetElement (const TRow &row, const TColumn &col) const
 Get table element. More...
 
TValueTypeGetElement (const TRow &row, const TColumn &col)
 Get table element. More...
 
const TValue & operator() (const TRow &row, const TColumn &col) const
 Get table element. More...
 
TValue & operator() (const TRow &row, const TColumn &col)
 Get table element. More...
 
unsigned int ColumnIdx (const TColumn &col) const
 Get column index. More...
 
unsigned int RowIdx (const TRow &row) const
 Get row index. More...
 
const TColumn & Column (unsigned int idx) const
 Get column name. More...
 
const TRow & Row (unsigned int idx) const
 Get row name. More...
 
const TValueTypeGetCell (unsigned int row_idx, unsigned int col_idx) const
 Access table element by index. More...
 
TValueTypeGetCell (unsigned int row_idx, unsigned int col_idx)
 Access table element by index. More...
 

Protected Types

typedef vector< TRowType * > TRowCollection
 

Protected Member Functions

void x_Free ()
 
void x_Copy (const CNcbiTable &table)
 

Protected Attributes

unsigned int m_Rows
 Number of rows. More...
 
unsigned int m_Cols
 Number of columns. More...
 
TRowMap m_RowMap
 Row name to index. More...
 
TColumnMap m_ColumnMap
 Column name to index. More...
 
TRowCollection m_Table
 

Detailed Description

template<class TValue, class TRow, class TColumn>
class CNcbiTable< TValue, TRow, TColumn >

Template class to create a table with custom row-column access.

Table provides two access modes one is using custom types associated with rows and columns and another using rows and columns integer indexes.

Definition at line 65 of file ncbi_table.hpp.

Member Typedef Documentation

◆ TColumnMap

template<class TValue , class TRow , class TColumn >
typedef map<TColumn, unsigned int> CNcbiTable< TValue, TRow, TColumn >::TColumnMap

Definition at line 69 of file ncbi_table.hpp.

◆ TRowCollection

template<class TValue , class TRow , class TColumn >
typedef vector<TRowType*> CNcbiTable< TValue, TRow, TColumn >::TRowCollection
protected

Definition at line 159 of file ncbi_table.hpp.

◆ TRowMap

template<class TValue , class TRow , class TColumn >
typedef map<TRow, unsigned int> CNcbiTable< TValue, TRow, TColumn >::TRowMap

Definition at line 68 of file ncbi_table.hpp.

◆ TRowType

template<class TValue , class TRow , class TColumn >
typedef vector<TValue> CNcbiTable< TValue, TRow, TColumn >::TRowType

Definition at line 72 of file ncbi_table.hpp.

◆ TValueType

template<class TValue , class TRow , class TColumn >
typedef TValue CNcbiTable< TValue, TRow, TColumn >::TValueType

Definition at line 70 of file ncbi_table.hpp.

Constructor & Destructor Documentation

◆ CNcbiTable() [1/3]

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::CNcbiTable

Definition at line 177 of file ncbi_table.hpp.

◆ CNcbiTable() [2/3]

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::CNcbiTable ( unsigned int  rows,
unsigned int  cols 
)

Construction.

Creates row x cols table without any row-column association

Definition at line 184 of file ncbi_table.hpp.

References i, CNcbiTable< TValue, TRow, TColumn >::m_Cols, CNcbiTable< TValue, TRow, TColumn >::m_Rows, CNcbiTable< TValue, TRow, TColumn >::m_Table, and r().

◆ CNcbiTable() [3/3]

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::CNcbiTable ( const CNcbiTable< TValue, TRow, TColumn > &  table)

Definition at line 197 of file ncbi_table.hpp.

References table.

◆ ~CNcbiTable()

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::~CNcbiTable

Definition at line 223 of file ncbi_table.hpp.

Member Function Documentation

◆ AddColumn()

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::AddColumn ( const TColumn &  col)

Add column to the table, column recieves name "col".

Definition at line 252 of file ncbi_table.hpp.

References NON_CONST_ITERATE, and r().

Referenced by CBioTreeAttrReader::Read().

◆ AddRow()

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::AddRow ( const TRow &  row)

Add row to the table, column recieves name "row".

Definition at line 264 of file ncbi_table.hpp.

References r().

Referenced by CBioTreeAttrReader::Read().

◆ AssociateColumn()

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::AssociateColumn ( const TColumn &  col,
unsigned int  col_idx 
)

Set up column name.

Definition at line 289 of file ncbi_table.hpp.

References NCBI_THROW.

◆ AssociateRow()

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::AssociateRow ( const TRow &  row,
unsigned int  row_idx 
)

Set up row name.

Definition at line 275 of file ncbi_table.hpp.

References NCBI_THROW.

◆ Cols()

template<class TValue , class TRow , class TColumn >
unsigned int CNcbiTable< TValue, TRow, TColumn >::Cols

Number of column.

Definition at line 246 of file ncbi_table.hpp.

Referenced by CBioTreeAttrReader::Read(), and CPhyloTreeCalculator::x_UpdateProperties().

◆ Column()

template<class TValue , class TRow , class TColumn >
const TColumn & CNcbiTable< TValue, TRow, TColumn >::Column ( unsigned int  idx) const

Get column name.

Definition at line 441 of file ncbi_table.hpp.

References NCBI_THROW.

Referenced by CPhyloTreeCalculator::SetAttrTable(), and CPhyloTreeCalculator::x_UpdateProperties().

◆ ColumnIdx()

template<class TValue , class TRow , class TColumn >
unsigned int CNcbiTable< TValue, TRow, TColumn >::ColumnIdx ( const TColumn &  col) const

Get column index.

Definition at line 415 of file ncbi_table.hpp.

References NCBI_THROW.

Referenced by CPhyloTreeCalculator::x_OnStep().

◆ GetCell() [1/2]

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::TValueType & CNcbiTable< TValue, TRow, TColumn >::GetCell ( unsigned int  row_idx,
unsigned int  col_idx 
)

Access table element by index.

Definition at line 476 of file ncbi_table.hpp.

References r().

◆ GetCell() [2/2]

template<class TValue , class TRow , class TColumn >
const CNcbiTable< TValue, TRow, TColumn >::TValueType & CNcbiTable< TValue, TRow, TColumn >::GetCell ( unsigned int  row_idx,
unsigned int  col_idx 
) const

◆ GetElement() [1/2]

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::TValueType & CNcbiTable< TValue, TRow, TColumn >::GetElement ( const TRow &  row,
const TColumn &  col 
)

Get table element.

Definition at line 404 of file ncbi_table.hpp.

◆ GetElement() [2/2]

template<class TValue , class TRow , class TColumn >
const CNcbiTable< TValue, TRow, TColumn >::TValueType & CNcbiTable< TValue, TRow, TColumn >::GetElement ( const TRow &  row,
const TColumn &  col 
) const

Get table element.

Definition at line 394 of file ncbi_table.hpp.

Referenced by CNcbiTable< TValue, TRow, TColumn >::operator()().

◆ GetRow()

template<class TValue , class TRow , class TColumn >
const CNcbiTable< TValue, TRow, TColumn >::TRowType & CNcbiTable< TValue, TRow, TColumn >::GetRow ( const TRow &  row) const

Get table row.

Definition at line 365 of file ncbi_table.hpp.

References NCBI_THROW.

◆ GetRowVector() [1/2]

template<class TValue , class TRow , class TColumn >
CNcbiTable< TValue, TRow, TColumn >::TRowType & CNcbiTable< TValue, TRow, TColumn >::GetRowVector ( unsigned int  row_idx)

Get table row by row index.

Definition at line 386 of file ncbi_table.hpp.

◆ GetRowVector() [2/2]

template<class TValue , class TRow , class TColumn >
const CNcbiTable< TValue, TRow, TColumn >::TRowType & CNcbiTable< TValue, TRow, TColumn >::GetRowVector ( unsigned int  row_idx) const

Get table row by row index.

Definition at line 379 of file ncbi_table.hpp.

◆ operator()() [1/2]

template<class TValue , class TRow , class TColumn >
TValue& CNcbiTable< TValue, TRow, TColumn >::operator() ( const TRow &  row,
const TColumn &  col 
)
inline

Get table element.

Definition at line 133 of file ncbi_table.hpp.

References CNcbiTable< TValue, TRow, TColumn >::GetElement().

◆ operator()() [2/2]

template<class TValue , class TRow , class TColumn >
const TValue& CNcbiTable< TValue, TRow, TColumn >::operator() ( const TRow &  row,
const TColumn &  col 
) const
inline

Get table element.

Definition at line 128 of file ncbi_table.hpp.

References CNcbiTable< TValue, TRow, TColumn >::GetElement().

◆ operator=()

template<class TValue , class TRow , class TColumn >
CNcbiTable& CNcbiTable< TValue, TRow, TColumn >::operator= ( const CNcbiTable< TValue, TRow, TColumn > &  table)
inline

◆ Resize() [1/2]

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::Resize ( unsigned int  rows,
unsigned int  cols 
)

Change table size.

Definition at line 304 of file ncbi_table.hpp.

References NON_CONST_ITERATE, and r().

◆ Resize() [2/2]

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::Resize ( unsigned int  rows,
unsigned int  cols,
const TValue &  v 
)

Change table size, new table elements initialized with value.

Definition at line 333 of file ncbi_table.hpp.

References NON_CONST_ITERATE, and r().

◆ Row()

template<class TValue , class TRow , class TColumn >
const TRow & CNcbiTable< TValue, TRow, TColumn >::Row ( unsigned int  idx) const

Get row name.

Definition at line 454 of file ncbi_table.hpp.

References NCBI_THROW.

◆ RowIdx()

template<class TValue , class TRow , class TColumn >
unsigned int CNcbiTable< TValue, TRow, TColumn >::RowIdx ( const TRow &  row) const

Get row index.

Definition at line 428 of file ncbi_table.hpp.

References NCBI_THROW.

◆ Rows()

template<class TValue , class TRow , class TColumn >
unsigned int CNcbiTable< TValue, TRow, TColumn >::Rows

Number of rows.

Definition at line 240 of file ncbi_table.hpp.

Referenced by CPhyloTreeCalculator::SetAttrTable(), and CPhyloTreeCalculator::x_OnStep().

◆ x_Copy()

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::x_Copy ( const CNcbiTable< TValue, TRow, TColumn > &  table)
protected

Definition at line 204 of file ncbi_table.hpp.

References i, r(), and table.

Referenced by CNcbiTable< TValue, TRow, TColumn >::operator=().

◆ x_Free()

template<class TValue , class TRow , class TColumn >
void CNcbiTable< TValue, TRow, TColumn >::x_Free ( void  )
protected

Definition at line 229 of file ncbi_table.hpp.

References NON_CONST_ITERATE, and r().

Referenced by CNcbiTable< TValue, TRow, TColumn >::operator=().

Member Data Documentation

◆ m_Cols

template<class TValue , class TRow , class TColumn >
unsigned int CNcbiTable< TValue, TRow, TColumn >::m_Cols
protected

Number of columns.

Definition at line 163 of file ncbi_table.hpp.

Referenced by CNcbiTable< TValue, TRow, TColumn >::CNcbiTable().

◆ m_ColumnMap

template<class TValue , class TRow , class TColumn >
TColumnMap CNcbiTable< TValue, TRow, TColumn >::m_ColumnMap
protected

Column name to index.

Definition at line 166 of file ncbi_table.hpp.

◆ m_RowMap

template<class TValue , class TRow , class TColumn >
TRowMap CNcbiTable< TValue, TRow, TColumn >::m_RowMap
protected

Row name to index.

Definition at line 165 of file ncbi_table.hpp.

◆ m_Rows

template<class TValue , class TRow , class TColumn >
unsigned int CNcbiTable< TValue, TRow, TColumn >::m_Rows
protected

Number of rows.

Definition at line 162 of file ncbi_table.hpp.

Referenced by CNcbiTable< TValue, TRow, TColumn >::CNcbiTable().

◆ m_Table

template<class TValue , class TRow , class TColumn >
TRowCollection CNcbiTable< TValue, TRow, TColumn >::m_Table
protected

Definition at line 168 of file ncbi_table.hpp.

Referenced by CNcbiTable< TValue, TRow, TColumn >::CNcbiTable().


The documentation for this class was generated from the following file:
Modified on Tue Feb 27 05:56:19 2024 by modify_doxy.py rev. 669887