<
classTValue,
classTRow,
classTColumn>
78 CNcbiTable(
unsigned introws,
unsigned intcols);
92 unsigned int Rows()
const;
94 unsigned int Cols()
const;
107 void Resize(
unsigned introws,
111 void Resize(
unsigned introws,
139 unsigned int ColumnIdx(
constTColumn& col)
const;
141 unsigned int RowIdx(
constTRow&
row)
const;
144 constTColumn&
Column(
unsigned intidx)
const;
146 constTRow&
Row(
unsigned intidx)
const;
176 template<
classTValue,
classTRow,
classTColumn>
183 template<
classTValue,
classTRow,
classTColumn>
190 for(
unsigned int i= 0;
i<
m_Rows; ++
i) {
196 template<
classTValue,
classTRow,
classTColumn>
203 template<
classTValue,
classTRow,
classTColumn>
206m_Rows =
table.Rows();
207m_Cols =
table.Cols();
210m_Table.reserve(m_Rows);
211 for(
unsigned int i= 0;
i< m_Rows; ++
i) {
214m_Table.push_back(
r);
217m_RowMap =
table.m_RowMap;
218m_ColumnMap =
table.m_ColumnMap;
222 template<
classTValue,
classTRow,
classTColumn>
228 template<
classTValue,
classTRow,
classTColumn>
239 template<
classTValue,
classTRow,
classTColumn>
245 template<
classTValue,
classTRow,
classTColumn>
251 template<
classTValue,
classTRow,
classTColumn>
254 unsigned intcidx = m_Cols;
255AssociateColumn(col, cidx);
258 r->push_back(TValue());
263 template<
classTValue,
classTRow,
classTColumn>
266 unsigned intridx = m_Rows;
268m_Table.push_back(
r);
270AssociateRow(
row, ridx);
274 template<
classTValue,
classTRow,
classTColumn>
276 unsigned introw_idx)
279 if(it == m_RowMap.end()) {
280m_RowMap.insert(pair<TRow, unsigned int>(
row, row_idx));
284eRowAlreadyExists,
"Cannot assign row key (already assigned).");
288 template<
classTValue,
classTRow,
classTColumn>
290 unsigned intcol_idx)
293 if(it == m_ColumnMap.end()) {
294m_ColumnMap.insert(pair<TColumn, unsigned int>(col, col_idx));
298eRowAlreadyExists,
"Cannot assign column key (already assigned).");
303 template<
classTValue,
classTRow,
classTColumn>
310m_Table.resize(rows);
314m_Table.resize(rows, 0);
325 if(
r->size() != cols) {
332 template<
classTValue,
classTRow,
classTColumn>
340m_Table.resize(rows);
344m_Table.resize(rows, 0);
355 if(
r->size() != cols) {
363 template<
classTValue,
classTRow,
classTColumn>
368 if(it == m_RowMap.end()) {
371eRowNotFound,
"Row not found.");
373 unsigned intidx = it->second;
374 return*(m_Table[idx]);
377 template<
classTValue,
classTRow,
classTColumn>
381 return*(m_Table[row_idx]);
384 template<
classTValue,
classTRow,
classTColumn>
388 return*(m_Table[row_idx]);
392 template<
classTValue,
classTRow,
classTColumn>
396 unsigned intridx = RowIdx(
row);
397 unsigned intcidx = ColumnIdx(col);
399 returnGetCell(ridx, cidx);
402 template<
classTValue,
classTRow,
classTColumn>
406 unsigned intridx = RowIdx(
row);
407 unsigned intcidx = ColumnIdx(col);
409 returnGetCell(ridx, cidx);
413 template<
classTValue,
classTRow,
classTColumn>
418 if(it == m_ColumnMap.end()) {
421eColumnNotFound,
"Column not found.");
426 template<
classTValue,
classTRow,
classTColumn>
431 if(it == m_RowMap.end()) {
434eRowNotFound,
"Row not found.");
439 template<
classTValue,
classTRow,
classTColumn>
444 for(it=m_ColumnMap.begin(); it!=m_ColumnMap.end(); ++it) {
445 if( (*it).second == idx )
452 template<
classTValue,
classTRow,
classTColumn>
457 for(it=m_RowMap.begin(); it!=m_RowMap.end(); ++it) {
458 if( (*it).second == idx )
465 template<
classTValue,
classTRow,
classTColumn>
468 unsigned intcol_idx)
const 470 const TRowType&
r= *(m_Table[row_idx]);
474 template<
classTValue,
classTRow,
classTColumn>
477 unsigned intcol_idx)
EErrCode
Exception types.
@ eRowNotFound
Row not found.
@ eColumnNotFound
Column not found.
@ eRowAlreadyExists
Row id has been assigned before.
NCBI_EXCEPTION_DEFAULT(CNcbiTable_Exception, CException)
Template class to create a table with custom row-column access.
map< TRow, unsigned int > TRowMap
const TColumn & Column(unsigned int idx) const
Get column name.
void AssociateColumn(const TColumn &col, unsigned int col_idx)
Set up column name.
TValue & operator()(const TRow &row, const TColumn &col)
Get table element.
void AddColumn(const TColumn &col)
Add column to the table, column recieves name "col".
unsigned int m_Rows
Number of rows.
void x_Copy(const CNcbiTable &table)
unsigned int ColumnIdx(const TColumn &col) const
Get column index.
const TValue & operator()(const TRow &row, const TColumn &col) const
Get table element.
unsigned int RowIdx(const TRow &row) const
Get row index.
void Resize(unsigned int rows, unsigned int cols)
Change table size.
TRowMap m_RowMap
Row name to index.
const TValueType & GetCell(unsigned int row_idx, unsigned int col_idx) const
Access table element by index.
const TRow & Row(unsigned int idx) const
Get row name.
const TRowType & GetRow(const TRow &row) const
Get table row.
unsigned int m_Cols
Number of columns.
map< TColumn, unsigned int > TColumnMap
void AddRow(const TRow &row)
Add row to the table, column recieves name "row".
unsigned int Rows() const
Number of rows.
const TValueType & GetElement(const TRow &row, const TColumn &col) const
Get table element.
unsigned int Cols() const
Number of column.
TColumnMap m_ColumnMap
Column name to index.
CNcbiTable & operator=(const CNcbiTable &table)
const TRowType & GetRowVector(unsigned int row_idx) const
Get table row by row index.
vector< TRowType * > TRowCollection
vector< TValue > TRowType
void AssociateRow(const TRow &row, unsigned int row_idx)
Set up row name.
container_type::const_iterator const_iterator
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
Defines NCBI C++ exception handling.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
NCBI_XUTIL_EXPORT
Parameter to control printing diagnostic message about conversion of static array data from a differe...
#define row(bind, expected)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4