diff --git a/libs/main/containers/pivector2d.h b/libs/main/containers/pivector2d.h index b55adbe5..c39938f0 100644 --- a/libs/main/containers/pivector2d.h +++ b/libs/main/containers/pivector2d.h @@ -274,6 +274,20 @@ public: mat.clear(); } + const PIVector2D & forEach(std::function f) const { + mat.forEach(f); + return *this; + } + PIVector2D copyForEach(std::function f) const { + PIVector2D ret(*this); + ret.mat = mat.copyForEach(f); + return ret; + } + PIVector2D & forEachInplace(std::function f) { + mat.forEachInplace(f); + return *this; + } + protected: size_t rows_, cols_; PIVector mat; diff --git a/libs/main/math/pimathvector.h b/libs/main/math/pimathvector.h index a98cef49..6dc54c69 100644 --- a/libs/main/math/pimathvector.h +++ b/libs/main/math/pimathvector.h @@ -25,6 +25,7 @@ #include "pimathbase.h" + template class PIMathMatrixT; @@ -445,6 +446,20 @@ public: PIVector toVector() const {return c;} + const _CVector & forEach(std::function f) const { + c.forEach(f); + return *this; + } + _CVector copyForEach(std::function f) const { + _CVector ret; + ret.c = c.copyForEach(f); + return ret; + } + _CVector & forEachInplace(std::function f) { + c.forEachInplace(f); + return *this; + } + inline Type * data() {return c.data();} inline const Type * data() const {return c.data();}