From 7ef17bfc3d3725293ef2a20059bfd5c73d731f5b Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 25 May 2023 18:10:49 +0300 Subject: [PATCH] Fix issue with keys order --- src/sfall_arrays.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sfall_arrays.cc b/src/sfall_arrays.cc index 98b2fbb..6d41cb6 100644 --- a/src/sfall_arrays.cc +++ b/src/sfall_arrays.cc @@ -383,10 +383,10 @@ public: throw(std::exception()); }; auto idx = it - keys.begin(); - if (idx != keys.size() - 1) { - std::swap(keys[idx], keys[size() - 1]); - keys.resize(keys.size() - 1); + for (size_t i = idx; i < size() - 1; i++) { + std::swap(keys[i], keys[i + 1]); } + keys.resize(keys.size() - 1); } } else { if (iter == map.end()) {