vector and maitrix foreach
This commit is contained in:
@@ -274,6 +274,20 @@ public:
|
|||||||
mat.clear();
|
mat.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PIVector2D<T> & forEach(std::function<void(const T &)> f) const {
|
||||||
|
mat.forEach(f);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
PIVector2D<T> copyForEach(std::function<T(const T &)> f) const {
|
||||||
|
PIVector2D<T> ret(*this);
|
||||||
|
ret.mat = mat.copyForEach(f);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
PIVector2D<T> & forEachInplace(std::function<T(const T &)> f) {
|
||||||
|
mat.forEachInplace(f);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t rows_, cols_;
|
size_t rows_, cols_;
|
||||||
PIVector<T> mat;
|
PIVector<T> mat;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "pimathbase.h"
|
#include "pimathbase.h"
|
||||||
|
|
||||||
|
|
||||||
template<uint Cols, uint Rows, typename Type>
|
template<uint Cols, uint Rows, typename Type>
|
||||||
class PIMathMatrixT;
|
class PIMathMatrixT;
|
||||||
|
|
||||||
@@ -445,6 +446,20 @@ public:
|
|||||||
|
|
||||||
PIVector<Type> toVector() const {return c;}
|
PIVector<Type> toVector() const {return c;}
|
||||||
|
|
||||||
|
const _CVector & forEach(std::function<void(const Type &)> f) const {
|
||||||
|
c.forEach(f);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
_CVector copyForEach(std::function<Type(const Type &)> f) const {
|
||||||
|
_CVector ret;
|
||||||
|
ret.c = c.copyForEach(f);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
_CVector & forEachInplace(std::function<Type(const Type &)> f) {
|
||||||
|
c.forEachInplace(f);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
inline Type * data() {return c.data();}
|
inline Type * data() {return c.data();}
|
||||||
inline const Type * data() const {return c.data();}
|
inline const Type * data() const {return c.data();}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user