Buffer append buff
This commit is contained in:
parent
ec2a71ccdb
commit
e29328a0dd
1 changed files with 12 additions and 1 deletions
|
|
@ -90,7 +90,7 @@ namespace tp {
|
|||
|
||||
Buffer& operator=(const Buffer& in) {
|
||||
if (this == &in) return *this;
|
||||
~Buffer();
|
||||
this->~Buffer();
|
||||
new (this) Buffer(in);
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -156,6 +156,16 @@ namespace tp {
|
|||
mLoad++;
|
||||
}
|
||||
|
||||
void append(const Buffer& in) {
|
||||
if (!in.mLoad) return;
|
||||
auto newLoad = mLoad + in.mLoad;
|
||||
auto newSize = mSize;
|
||||
while (newLoad >= newSize) newSize = tResizePolicy(newSize);
|
||||
if (newSize != mSize) resizeBuffer(newSize);
|
||||
for (auto i = mLoad; i < newLoad; i++) new (&mBuff[i]) tType(in.mBuff[i - mLoad]);
|
||||
mLoad = newLoad;
|
||||
}
|
||||
|
||||
void pop() {
|
||||
DEBUG_ASSERT(mLoad)
|
||||
mBuff[mLoad].~tType();
|
||||
|
|
@ -165,6 +175,7 @@ namespace tp {
|
|||
if (prevSize > mLoad) resizeBuffer(prevSize);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void resizeBuffer(ualni newSize) {
|
||||
DEBUG_ASSERT(newSize >= mLoad)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue