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