mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-31 02:48:31 +00:00
Remove SparseOHArray::insert
This commit is contained in:
parent
73023bcb5d
commit
6295da436f
@ -246,7 +246,19 @@ QPDF_Array::insert(int at, QPDFObjectHandle const& item)
|
||||
} else {
|
||||
checkOwnership(item);
|
||||
if (sparse) {
|
||||
sp_elements.insert(at, item);
|
||||
auto iter = sp_elements.elements.crbegin();
|
||||
while (iter != sp_elements.elements.crend()) {
|
||||
auto key = (iter++)->first;
|
||||
if (key >= at) {
|
||||
auto nh = sp_elements.elements.extract(key);
|
||||
++nh.key();
|
||||
sp_elements.elements.insert(std::move(nh));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
sp_elements.elements[at] = item.getObj();
|
||||
++sp_elements.n_elements;
|
||||
} else {
|
||||
elements.insert(elements.cbegin() + at, item.getObj());
|
||||
}
|
||||
|
@ -49,29 +49,6 @@ SparseOHArray::erase(int at)
|
||||
--n_elements;
|
||||
}
|
||||
|
||||
void
|
||||
SparseOHArray::insert(int idx, QPDFObjectHandle oh)
|
||||
{
|
||||
if (idx == n_elements) {
|
||||
// Allow inserting to the last position
|
||||
append(oh);
|
||||
} else {
|
||||
auto iter = elements.crbegin();
|
||||
while (iter != elements.crend()) {
|
||||
auto key = (iter++)->first;
|
||||
if (key >= idx) {
|
||||
auto nh = elements.extract(key);
|
||||
++nh.key();
|
||||
elements.insert(std::move(nh));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
elements[idx] = oh.getObj();
|
||||
++n_elements;
|
||||
}
|
||||
}
|
||||
|
||||
SparseOHArray
|
||||
SparseOHArray::copy()
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ class SparseOHArray
|
||||
elements[idx] = oh.getObj();
|
||||
}
|
||||
void erase(int idx);
|
||||
void insert(int idx, QPDFObjectHandle oh);
|
||||
SparseOHArray copy();
|
||||
void disconnect();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user