42 Table(std::initializer_list<std::initializer_list<T>> table)
47 qsizetype headerWidth = table.begin()->size();
49 for(
auto itr = table.begin(); itr != table.end(); itr++)
51 if(itr->size() != headerWidth)
63 T&
at(qsizetype r, qsizetype c)
65 Q_ASSERT_X(
size_t(r) <
size_t(
rowCount()) &&
size_t(c) <
size_t(
columnCount()), Q_FUNC_INFO,
"index out of range");
70 const T&
at(qsizetype r, qsizetype c)
const
72 Q_ASSERT_X(
size_t(r) <
size_t(
rowCount()) &&
size_t(c) <
size_t(
columnCount()), Q_FUNC_INFO,
"index out of range");
82 return QSize(rowCap, colCap);
87 Q_ASSERT_X(
size_t(i) <
size_t(
columnCount()), Q_FUNC_INFO,
"index out of range");
132 Q_ASSERT_X(i <
rowCount(), Q_FUNC_INFO,
"index out of range");
158 row = row.sliced(c,
height);
165 T
value(qsizetype r, qsizetype c)
const {
return value(r, c, T()); }
167 T
value(qsizetype r, qsizetype c,
const T& defaultValue)
const
184 mTable[i].append(i > c.
size() - 1 ? T() : c[i]);
213 Q_ASSERT_X(i >= 0 && i <=
columnCount(),
"QTable<T>::insertColumn",
"index out of range");
224 for(qsizetype r = 0; r < rows; r++)
225 mTable[r].insert(i, r > c.
size() - 1 ? T() : c[r]);
230 Q_ASSERT_X(i >= 0 && i <=
rowCount(),
"QTable<T>::insertRow",
"index out of range");
234 if(r.
size() > columns)
242 if(r.
size() < columns)
250 Q_ASSERT_X(
size_t(i) +
size_t(n) <=
size_t(
columnCount()), Q_FUNC_INFO,
"index out of range");
251 Q_ASSERT_X(n >= 0, Q_FUNC_INFO,
"invalid count");
264 Q_ASSERT_X(
size_t(i) +
size_t(n) <=
size_t(
rowCount()), Q_FUNC_INFO,
"index out of range");
265 Q_ASSERT_X(n >= 0, Q_FUNC_INFO,
"invalid count");
303 qsizetype rowGrowth = rows - c.
size();
308 for(qsizetype r = 0; r < rows; r++)
309 mTable[r].replace(i, r > c.
size() - 1 ? T() : c[r]);
316 qsizetype columnGrowth = columns - r.
size();
367 qsizetype growth =
size - currentSize;
372 if(growth > 0 && columns > 0)
375 for(qsizetype r = currentSize; r <
rowCount(); r++)
389 Q_ASSERT_X(
size_t(i) <
size_t(
columnCount()), Q_FUNC_INFO,
"index out of range");
424 Q_ASSERT_X(
size_t(i) <
size_t(
rowCount()), Q_FUNC_INFO,
"index out of range");
The Table class is a template class that provides a dynamic two-dimensional array.
Definition qx-table.h:13
void removeColumnAt(qsizetype i)
Definition qx-table.h:246
qsizetype height() const
Definition qx-table.h:112
void insertColumn(qsizetype i, const QList< T > &c)
Definition qx-table.h:211
void removeColumns(qsizetype i, qsizetype n=1)
Definition qx-table.h:248
Table(QSize size)
Definition qx-table.h:29
Table(QSize size, const T &value)
Definition qx-table.h:36
void fill(const T &value, QSize size)
Definition qx-table.h:202
T value(qsizetype r, qsizetype c) const
Definition qx-table.h:165
row_iterator rowBegin() const
Definition qx-table.h:137
Table(std::initializer_list< std::initializer_list< T > > table)
Definition qx-table.h:42
void resize(QSize size)
Definition qx-table.h:343
T value(qsizetype r, qsizetype c, const T &defaultValue) const
Definition qx-table.h:167
QList< QList< T > > mTable
Definition qx-table.h:23
QList< QList< T > >::const_iterator row_iterator
Definition qx-table.h:16
Table section(qsizetype r, qsizetype c, qsizetype height, qsizetype width) const
Definition qx-table.h:143
bool operator!=(const Table &other) const
Definition qx-table.h:432
QList< T > takeLastColumn()
Definition qx-table.h:408
Table()
Definition qx-table.h:27
qsizetype rowCount() const
Definition qx-table.h:139
bool isEmpty() const
Definition qx-table.h:114
row_iterator rowEnd() const
Definition qx-table.h:141
void appendRow(const QList< T > &r)
Definition qx-table.h:187
QList< T > takeFirstRow()
Definition qx-table.h:402
void removeLastColumn()
Definition qx-table.h:285
const QList< T > & rowAt(qsizetype i) const
Definition qx-table.h:130
void removeFirstColumn()
Definition qx-table.h:273
QList< T > takeColumnAt(qsizetype i)
Definition qx-table.h:387
qsizetype width() const
Definition qx-table.h:429
qsizetype columnCount() const
Definition qx-table.h:98
const T & at(qsizetype r, qsizetype c) const
Definition qx-table.h:70
bool operator==(const Table &other) const
Definition qx-table.h:431
void removeRows(qsizetype i, qsizetype n=1)
Definition qx-table.h:262
QList< T > firstColumn() const
Definition qx-table.h:100
QList< T > columnAt(qsizetype i) const
Definition qx-table.h:85
QList< T > takeRowAt(qsizetype i)
Definition qx-table.h:422
const QList< T > & firstRow() const
Definition qx-table.h:106
QSize size() const
Definition qx-table.h:163
void appendColumn(const QList< T > &c)
Definition qx-table.h:176
T & at(qsizetype r, qsizetype c)
Definition qx-table.h:63
void addRows(qsizetype r)
Definition qx-table.h:174
void addColumns(qsizetype c)
Definition qx-table.h:172
const QList< T > & lastRow() const
Definition qx-table.h:123
void removeFirstRow()
Definition qx-table.h:279
QList< T > takeFirstColumn()
Definition qx-table.h:396
void replaceColumn(qsizetype i, const QList< T > &c)
Definition qx-table.h:299
void resizeColumns(qsizetype size)
Definition qx-table.h:352
void removeRowAt(qsizetype i)
Definition qx-table.h:260
void removeLastRow()
Definition qx-table.h:292
QList< T > lastColumn() const
Definition qx-table.h:116
void replaceRow(qsizetype i, const QList< T > &r)
Definition qx-table.h:312
void resizeRows(qsizetype size)
Definition qx-table.h:361
void squeeze()
Definition qx-table.h:380
void reserve(QSize size)
Definition qx-table.h:326
void insertRow(qsizetype i, const QList< T > &r)
Definition qx-table.h:228
QList< T > takeLastRow()
Definition qx-table.h:415
QSize capacity() const
Definition qx-table.h:77
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
void append(QList< T > &&value)
QList< T >::const_reference at(qsizetype i) const const
QList< T >::reference back()
qsizetype capacity() const const
QList< T >::const_iterator constBegin() const const
QList< T >::const_iterator constEnd() const const
QList< T >::iterator insert(QList< T >::const_iterator before, QList< T >::parameter_type value)
bool isEmpty() const const
void remove(qsizetype i, qsizetype n)
void replace(qsizetype i, QList< T >::parameter_type value)
void reserve(qsizetype size)
void resize(qsizetype size)
qsizetype size() const const
QList< T > sliced(qsizetype pos) const const
bool isNull() const const