diff --git a/main.cpp b/main.cpp index 0cd59dea..f911bf4c 100644 --- a/main.cpp +++ b/main.cpp @@ -1,14 +1,14 @@ #include "pip.h" -PIKbdListener kbd(0, 0, false); int main() { - //PISystemInfo::machineID(); - kbd.enableExitCapture(); - PIThread t; - t.start(10); - //WAIT_FOR_EXIT; - piSleep(20.); - t.stop(); + PIVector v; + for (int i=0; i<9; ++i) v << i; + PIVector2D v2(3,3,v); + piCout << v2; + v2.addRow(PIVector() << 99 << 88 << 77 << 66); + v2.addRow(v2.row(1)); + piCout << v2; return 0; } + diff --git a/src_main/containers/pivector2d.h b/src_main/containers/pivector2d.h index 604bf9f0..3de31062 100644 --- a/src_main/containers/pivector2d.h +++ b/src_main/containers/pivector2d.h @@ -170,7 +170,12 @@ public: inline Col col(size_t index) {return Col(this, index);} inline ColConst col(size_t index) const {return ColConst(this, index);} inline PIVector2D & setRow(size_t row, const Row & other) { - size_t sz = piMin(cols_, other.p_->cols_); + size_t sz = piMin(cols_, other.sz_); + mat._copyRaw(mat.data(cols_ * row), other.data(), sz); + return *this; + } + inline PIVector2D & setRow(size_t row, const RowConst & other) { + size_t sz = piMin(cols_, other.sz_); mat._copyRaw(mat.data(cols_ * row), other.data(), sz); return *this; } @@ -179,6 +184,30 @@ public: mat._copyRaw(mat.data(cols_ * row), other.data(), sz); return *this; } + inline PIVector2D & addRow(const Row & other) { + size_t sz = piMin(cols_, other.sz_); + size_t ps = mat.size(); + mat.resize(mat.size() + cols_); + mat._copyRaw(mat.data(ps), other.data(), sz); + rows_++; + return *this; + } + inline PIVector2D & addRow(const RowConst & other) { + size_t sz = piMin(cols_, other.sz_); + size_t ps = mat.size(); + mat.resize(mat.size() + cols_); + mat._copyRaw(mat.data(ps), other.data(), sz); + rows_++; + return *this; + } + inline PIVector2D & addRow(const PIVector & other) { + size_t sz = piMin(cols_, other.size()); + size_t ps = mat.size(); + mat.resize(mat.size() + cols_); + mat._copyRaw(mat.data(ps), other.data(), sz); + rows_++; + return *this; + } PIVector > toVectors() const { PIVector > ret;