18#ifndef PM_BASE_MATRIX_RA_H
19#define PM_BASE_MATRIX_RA_H
32struct Dummy_matrix_row_access {
33 Dummy_matrix_row_access([[maybe_unused]]
unsigned int numberOfRows = 0) {};
35 friend void swap([[maybe_unused]] Dummy_matrix_row_access& d1, [[maybe_unused]] Dummy_matrix_row_access& d2)
noexcept
52template <
typename Row,
typename Row_container,
bool has_removable_rows,
typename ID_index>
70 if constexpr (!has_removable_rows) {
71 rows_->resize(numberOfRows);
81 : rows_(new Row_container())
83 if constexpr (!has_removable_rows) {
84 rows_->resize(toCopy.rows_->size());
110 if constexpr (has_removable_rows) {
111 return rows_->at(rowIndex);
113 return rows_->operator[](rowIndex);
127 if constexpr (has_removable_rows) {
128 return rows_->at(rowIndex);
130 return rows_->operator[](rowIndex);
142 static_assert(has_removable_rows,
"'erase_empty_row' is not implemented for the chosen options.");
144 auto it = rows_->find(rowIndex);
145 if (it != rows_->end() && it->second.empty()) rows_->erase(it);
153 if constexpr (has_removable_rows)
154 rows_->reserve(other.rows_->size());
156 rows_->resize(other.rows_->size());
165 if (
this == &other)
return *
this;
167 rows_ = std::exchange(other.rows_,
nullptr);
176 std::swap(matrix1.rows_, matrix2.rows_);
180 Row_container* _get_rows_ptr()
const {
return rows_; }
182 void _resize(ID_index size)
184 static_assert(!has_removable_rows,
"'_resize' is not implemented for the chosen options.");
186 if (rows_->size() <= size) rows_->resize(size + 1);
194 Row_container* rows_;
friend void swap(Matrix_row_access &matrix1, Matrix_row_access &matrix2) noexcept
Swap operator.
Definition matrix_row_access.h:174
const Row & get_row(ID_index rowIndex) const
Returns the row at the given row index. The type of the row depends on the chosen options,...
Definition matrix_row_access.h:125
Matrix_row_access()
Default constructor.
Definition matrix_row_access.h:59
Matrix_row_access & operator=(const Matrix_row_access &other)
Assign operator.
Definition matrix_row_access.h:151
~Matrix_row_access()
Destructor.
Definition matrix_row_access.h:98
Matrix_row_access & operator=(Matrix_row_access &&other) noexcept
Move assign operator.
Definition matrix_row_access.h:163
void erase_empty_row(ID_index rowIndex)
Only available if PersistenceMatrixOptions::has_removable_rows is true. Removes the given row from th...
Definition matrix_row_access.h:140
Row & get_row(ID_index rowIndex)
Returns the row at the given row index. The type of the row depends on the chosen options,...
Definition matrix_row_access.h:108
Matrix_row_access(const Matrix_row_access &toCopy)
Copy constructor.
Definition matrix_row_access.h:80
Matrix_row_access(unsigned int numberOfRows)
Constructor reserving space for the given number of rows.
Definition matrix_row_access.h:68
Matrix_row_access(Matrix_row_access &&other) noexcept
Move constructor.
Definition matrix_row_access.h:93
Persistence matrix namespace.
Definition FieldOperators.h:18
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14