From 477c9dc25643843cc3fa22e0c5c2f1a8c457da0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Tue, 11 Jun 2019 12:52:12 +0000 Subject: [PATCH] addRow in PIVector2D git-svn-id: svn://db.shs.com.ru/pip@799 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- main.cpp | 16 ++++++++-------- src_main/containers/pivector2d.h | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 9 deletions(-) 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;