git-svn-id: svn://db.shs.com.ru/pip@656 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -93,6 +93,7 @@ public:
|
||||
p_->copyRow(st_, other.data(), sz);
|
||||
return *this;
|
||||
}
|
||||
inline PIVector<T> toVector() const {return PIVector<T>(p_->mat.data(st_), p_->cols_);}
|
||||
};
|
||||
|
||||
class RowConst {
|
||||
@@ -105,6 +106,7 @@ public:
|
||||
inline size_t size() const {return p_->cols_;}
|
||||
inline const T & operator [](size_t index) const {return p_->mat[st_ + index];}
|
||||
inline const T * data(size_t index = 0) const {return p_->mat.data(st_ + index);}
|
||||
inline PIVector<T> toVector() const {return PIVector<T>(p_->mat.data(st_), p_->cols_);}
|
||||
};
|
||||
|
||||
|
||||
@@ -114,6 +116,12 @@ public:
|
||||
inline const T * data(size_t index = 0) const {return mat.data(index);}
|
||||
|
||||
inline Row row(size_t index) {return Row(this, index);}
|
||||
inline PIVector<T> col(size_t index) {
|
||||
PIVector<T> ret;
|
||||
ret.reserve(rows_);
|
||||
for (int i=0; i<rows_; i++) ret << mat[i*cols_+index];
|
||||
return ret;
|
||||
}
|
||||
inline PIVector2D<T> & setRow(size_t row, const Row & other) {
|
||||
size_t sz = piMin<size_t>(cols_, other.p_->cols_);
|
||||
copyRow(cols_ * row, other.data(), sz);
|
||||
@@ -135,18 +143,25 @@ public:
|
||||
PIVector<T> & plainVector() {return mat;}
|
||||
const PIVector<T> & plainVector() const {return mat;}
|
||||
|
||||
inline void swap(PIVector2D<T> & other) {
|
||||
mat.swap(other.mat);
|
||||
piSwap<size_t>(rows_, other.rows_);
|
||||
piSwap<size_t>(cols_, other.cols_);
|
||||
}
|
||||
|
||||
inline PIVector2D<T> & _resizeRaw(size_t r, size_t c) {
|
||||
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIVECTOR_SIMPLE_TYPE__ macro!";
|
||||
assert(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
inline void copyRow(size_t start, const T * data, size_t size) {
|
||||
for (size_t i = 0; i < size; i++)
|
||||
mat[start + i] = data[i];
|
||||
}
|
||||
|
||||
//private:
|
||||
size_t rows_, cols_;
|
||||
PIVector<T> mat;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user