2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Remove SparseOHArray::erase

This commit is contained in:
m-holger 2023-03-29 15:53:34 +01:00
parent 6295da436f
commit 1c85e7ece4
3 changed files with 14 additions and 21 deletions

View File

@ -284,7 +284,20 @@ QPDF_Array::erase(int at)
return false; return false;
} }
if (sparse) { if (sparse) {
sp_elements.erase(at); auto end = sp_elements.elements.end();
if (auto iter = sp_elements.elements.lower_bound(at); iter != end) {
if (iter->first == at) {
iter++;
sp_elements.elements.erase(at);
}
while (iter != end) {
auto nh = sp_elements.elements.extract(iter++);
--nh.key();
sp_elements.elements.insert(std::move(nh));
}
}
--sp_elements.n_elements;
} else { } else {
elements.erase(elements.cbegin() + at); elements.erase(elements.cbegin() + at);
} }

View File

@ -30,25 +30,6 @@ SparseOHArray::disconnect()
} }
} }
void
SparseOHArray::erase(int at)
{
auto end = elements.end();
if (auto iter = elements.lower_bound(at); iter != end) {
if (iter->first == at) {
iter++;
elements.erase(at);
}
while (iter != end) {
auto nh = elements.extract(iter++);
--nh.key();
elements.insert(std::move(nh));
}
}
--n_elements;
}
SparseOHArray SparseOHArray
SparseOHArray::copy() SparseOHArray::copy()
{ {

View File

@ -33,7 +33,6 @@ class SparseOHArray
{ {
elements[idx] = oh.getObj(); elements[idx] = oh.getObj();
} }
void erase(int idx);
SparseOHArray copy(); SparseOHArray copy();
void disconnect(); void disconnect();