touched up Array
This commit is contained in:
parent
087faf9f67
commit
682cefde1b
@ -243,7 +243,7 @@ protected:
|
|||||||
for (index = 0; index < cnt; index++)
|
for (index = 0; index < cnt; index++)
|
||||||
{
|
{
|
||||||
// move-construct(or copy-construct) each element.
|
// move-construct(or copy-construct) each element.
|
||||||
new((QSE::Mmgr*)QSE_NULL, &tmp[index]) T((T&&)srcbuf[index]);
|
new((QSE::Mmgr*)QSE_NULL, &tmp[index]) T(QSE_CPP_RVREF(srcbuf[index]));
|
||||||
this->_positioner (tmp[index], index);
|
this->_positioner (tmp[index], index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +259,8 @@ protected:
|
|||||||
// the original array can get into an unknown state eventually.
|
// the original array can get into an unknown state eventually.
|
||||||
// i don't attempt to restore the moved object as an exception
|
// i don't attempt to restore the moved object as an exception
|
||||||
// may be raised during restoration.
|
// may be raised during restoration.
|
||||||
// an exception
|
//
|
||||||
|
// TODO: reconsider if this unwinding is needed
|
||||||
//try { new((QSE::Mmgr*)QSE_NULL, &srcbuf[index]) T((T&&)tmp[index]); }
|
//try { new((QSE::Mmgr*)QSE_NULL, &srcbuf[index]) T((T&&)tmp[index]); }
|
||||||
//catch (...) {}
|
//catch (...) {}
|
||||||
|
|
||||||
@ -299,13 +300,13 @@ protected:
|
|||||||
{
|
{
|
||||||
// no value exists in the given position.
|
// no value exists in the given position.
|
||||||
// i can move-construct the value.
|
// i can move-construct the value.
|
||||||
new((QSE::Mmgr*)QSE_NULL, &this->buffer[index]) T((T&&)value);
|
new((QSE::Mmgr*)QSE_NULL, &this->buffer[index]) T(QSE_CPP_RVREF(value));
|
||||||
this->_positioner (this->buffer[index], index);
|
this->_positioner (this->buffer[index], index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// there is an old value in the position. do move-assignment.
|
// there is an old value in the position. do move-assignment.
|
||||||
this->buffer[index] = (T&&)value;
|
this->buffer[index] = QSE_CPP_RVREF(value);
|
||||||
this->_positioner (this->buffer[index], index);
|
this->_positioner (this->buffer[index], index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,7 +422,7 @@ public:
|
|||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
#if defined(QSE_ENABLE_CPP11_MOVE)
|
||||||
void setValueAt (qse_size_t index, T&& value)
|
void setValueAt (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
this->update (index, (T&&)value);
|
this->update (index, QSE_CPP_RVREF(value));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -453,7 +454,7 @@ protected:
|
|||||||
for (qse_size_t i = this->count; i > index; i--)
|
for (qse_size_t i = this->count; i > index; i--)
|
||||||
{
|
{
|
||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
#if defined(QSE_ENABLE_CPP11_MOVE)
|
||||||
this->put_item_by_moving (i, (T&&)this->buffer[i - 1]);
|
this->put_item_by_moving (i, QSE_CPP_RVREF(this->buffer[i - 1]));
|
||||||
#else
|
#else
|
||||||
this->put_item (i, this->buffer[i - 1]);
|
this->put_item (i, this->buffer[i - 1]);
|
||||||
#endif
|
#endif
|
||||||
@ -500,7 +501,7 @@ public:
|
|||||||
this->secure_slot (index);
|
this->secure_slot (index);
|
||||||
|
|
||||||
//this->buffer[index] = value;
|
//this->buffer[index] = value;
|
||||||
this->put_item_by_moving (index, (T&&)value);
|
this->put_item_by_moving (index, QSE_CPP_RVREF(value));
|
||||||
if (index > this->count) this->count = index + 1;
|
if (index > this->count) this->count = index + 1;
|
||||||
else this->count++;
|
else this->count++;
|
||||||
|
|
||||||
@ -520,7 +521,7 @@ public:
|
|||||||
qse_size_t update (qse_size_t index, T&& value)
|
qse_size_t update (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
QSE_ASSERT (index < this->count);
|
QSE_ASSERT (index < this->count);
|
||||||
this->buffer[index] = (T&&)value;
|
this->buffer[index] = QSE_CPP_RVREF(value);
|
||||||
this->_positioner (this->buffer[index], index);
|
this->_positioner (this->buffer[index], index);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@ -538,9 +539,9 @@ public:
|
|||||||
qse_size_t upsert (qse_size_t index, T&& value)
|
qse_size_t upsert (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
if (index < this->count)
|
if (index < this->count)
|
||||||
return this->update (index, (T&&)value);
|
return this->update (index, QSE_CPP_RVREF(value));
|
||||||
else
|
else
|
||||||
return this->insert (index, (T&&)value);
|
return this->insert (index, QSE_CPP_RVREF(value));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -558,7 +559,7 @@ public:
|
|||||||
if (index < this->count)
|
if (index < this->count)
|
||||||
return index; // no update
|
return index; // no update
|
||||||
else
|
else
|
||||||
return this->insert (index, (T&&)value);
|
return this->insert (index, QSE_CPP_RVREF(value));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -591,11 +592,7 @@ public:
|
|||||||
//this->_positioner (this->buffer[j], j);
|
//this->_positioner (this->buffer[j], j);
|
||||||
|
|
||||||
// 2. operator assignment
|
// 2. operator assignment
|
||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
this->buffer[j] = QSE_CPP_RVREF(this->buffer[i]);
|
||||||
this->buffer[j] = (T&&)this->buffer[i];
|
|
||||||
#else
|
|
||||||
this->buffer[j] = this->buffer[i];
|
|
||||||
#endif
|
|
||||||
this->_positioner (this->buffer[j], j);
|
this->_positioner (this->buffer[j], j);
|
||||||
|
|
||||||
j++; i++;
|
j++; i++;
|
||||||
@ -775,41 +772,24 @@ public:
|
|||||||
{
|
{
|
||||||
last = first + nk;
|
last = first + nk;
|
||||||
index = first;
|
index = first;
|
||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
c = QSE_CPP_RVREF(this->buffer[index]);
|
||||||
c = (T&&)this->buffer[index];
|
|
||||||
#else
|
|
||||||
c = this->buffer[index];
|
|
||||||
#endif
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
while (index < nk)
|
while (index < nk)
|
||||||
{
|
{
|
||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
this->buffer[index] = QSE_CPP_RVREF(this->buffer[index + n]);
|
||||||
this->buffer[index] = (T&&)this->buffer[index + n];
|
|
||||||
#else
|
|
||||||
this->buffer[index] = this->buffer[index + n];
|
|
||||||
#endif
|
|
||||||
this->_positioner (this->buffer[index], index);
|
this->_positioner (this->buffer[index], index);
|
||||||
index += n;
|
index += n;
|
||||||
}
|
}
|
||||||
if (index == last) break;
|
if (index == last) break;
|
||||||
|
|
||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
this->buffer[index] = QSE_CPP_RVREF(this->buffer[index - nk]);
|
||||||
this->buffer[index] = (T&&)this->buffer[index - nk];
|
|
||||||
#else
|
|
||||||
this->buffer[index] = this->buffer[index - nk];
|
|
||||||
#endif
|
|
||||||
this->_positioner (this->buffer[index], index);
|
this->_positioner (this->buffer[index], index);
|
||||||
index -= nk;
|
index -= nk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->buffer[last] = QSE_CPP_RVREF(c);
|
||||||
#if defined(QSE_ENABLE_CPP11_MOVE)
|
|
||||||
this->buffer[last] = (T&&)c;
|
|
||||||
#else
|
|
||||||
this->buffer[last] = c;
|
|
||||||
#endif
|
|
||||||
this->_positioner (this->buffer[last], last);
|
this->_positioner (this->buffer[last], last);
|
||||||
first++;
|
first++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user