PIVector2D - add funcs, optimize, tests, fixes, doxygen #194
@@ -1219,14 +1219,21 @@ public:
|
|||||||
//! \sa removeRow(), PIVector::remove()
|
//! \sa removeRow(), PIVector::remove()
|
||||||
inline PIVector2D<T> & removeColumn(size_t col) {
|
inline PIVector2D<T> & removeColumn(size_t col) {
|
||||||
if (col >= cols_ || rows_ == 0) return *this;
|
if (col >= cols_ || rows_ == 0) return *this;
|
||||||
PIVector2D<T> result(rows_, cols_ - 1);
|
|
||||||
for (size_t r = 0; r < rows_; ++r) {
|
for (size_t r = 0; r < rows_; ++r) {
|
||||||
for (size_t c = 0, nc = 0; c < cols_; ++c) {
|
T * dst = mat.data(r * (cols_ - 1));
|
||||||
if (c == col) continue;
|
T * src = mat.data(r * cols_);
|
||||||
result.element(r, nc++) = element(r, c);
|
if (col > 0) {
|
||||||
|
memmove(dst, src, col * sizeof(T));
|
||||||
|
dst += col;
|
||||||
|
src += col;
|
||||||
|
}
|
||||||
|
size_t remaining = (cols_ - 1) - col;
|
||||||
|
if (remaining > 0) {
|
||||||
|
memmove(dst, src + 1, remaining * sizeof(T));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
swap(result);
|
cols_--;
|
||||||
|
mat.resize(rows_ * cols_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user