array2D: further small changes
This commit is contained in:
parent
04854518a3
commit
5c932f6668
@ -76,9 +76,9 @@ private:
|
|||||||
void initRows(ssize_t h, int offset = 0)
|
void initRows(ssize_t h, int offset = 0)
|
||||||
{
|
{
|
||||||
rows.resize(h);
|
rows.resize(h);
|
||||||
T* start = buffer.data();
|
T* start = buffer.data() + offset;
|
||||||
for (ssize_t i = 0; i < h; i++) {
|
for (ssize_t i = 0; i < h; ++i) {
|
||||||
rows[i] = start + offset + width * i;
|
rows[i] = start + width * i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,26 +106,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// creator type 2
|
// creator type 2
|
||||||
array2D(int w, int h, T ** source, unsigned int flags = 0) :
|
array2D(int w, int h, T ** source, unsigned int flags = 0) : width(w)
|
||||||
width(w)
|
|
||||||
{
|
{
|
||||||
const bool owner = !(flags & ARRAY2D_BYREFERENCE);
|
|
||||||
if (owner) {
|
|
||||||
buffer.resize(h * width);
|
|
||||||
} else {
|
|
||||||
buffer.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
rows.resize(h);
|
rows.resize(h);
|
||||||
|
if (!(flags & ARRAY2D_BYREFERENCE)) {
|
||||||
|
buffer.resize(h * width);
|
||||||
T* start = buffer.data();
|
T* start = buffer.data();
|
||||||
for (ssize_t i = 0; i < h; ++i) {
|
for (ssize_t i = 0; i < h; ++i) {
|
||||||
if (owner) {
|
|
||||||
rows[i] = start + i * width;
|
rows[i] = start + i * width;
|
||||||
for (ssize_t j = 0; j < width; ++j) {
|
for (ssize_t j = 0; j < width; ++j) {
|
||||||
rows[i][j] = source[i][j];
|
rows[i][j] = source[i][j];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
for (ssize_t i = 0; i < h; ++i) {
|
||||||
rows[i] = source[i];
|
rows[i] = source[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user