fix filterElements

This commit is contained in:
2026-02-18 20:03:27 +03:00
parent 52c400915d
commit 39c1be6bc0

View File

@@ -1668,16 +1668,12 @@ public:
return result;
}
//! \~english Returns a new 2D array (as a single row) containing only the elements that pass the test.
//! \~russian Возвращает новый двумерный массив (в виде одной строки), содержащий только элементы, прошедшие проверку.
//! \~english Returns a new plain array containing only the elements that pass the test.
//! \~russian Возвращает новый одноменый массив, содержащий только элементы, прошедшие проверку.
//! \param test Predicate taking a const T&.
//! \return A 1xN 2D array with the filtered elements (or empty).
//! \return PIVector<T> with the filtered elements (or empty).
//! \sa PIVector::filter()
inline PIVector2D<T> filterElements(std::function<bool(const T &)> test) const {
PIVector<T> filtered = mat.filter(test);
if (filtered.isEmpty()) return PIVector2D<T>();
return PIVector2D<T>(1, filtered.size(), filtered);
}
inline PIVector<T> filterElements(std::function<bool(const T &)> test) const { return mat.filter(test); }
protected:
size_t rows_, cols_;