mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-27 21:08:44 +08:00
Merge remote-tracking branch 'origin/hotfix/multimap_erase_bug' into development
This commit is contained in:
commit
ba903e37ba
@ -593,6 +593,11 @@ namespace etl
|
||||
// otherwise we might lose the other child of the swap node
|
||||
replacement = swap->children[1 - swap->dir];
|
||||
|
||||
if (replacement != nullptr)
|
||||
{
|
||||
replacement->parent = swap->parent;
|
||||
}
|
||||
|
||||
// Point swap node to detached node's parent, children and weight
|
||||
swap->parent = detached->parent;
|
||||
swap->children[(uint_least8_t) kLeft] = detached->children[(uint_least8_t) kLeft];
|
||||
|
||||
@ -276,6 +276,11 @@ namespace etl
|
||||
// otherwise we might lose the other child of the swap node
|
||||
replacement = swap->children[1 - swap->dir];
|
||||
|
||||
if (replacement != nullptr)
|
||||
{
|
||||
replacement->parent = swap->parent;
|
||||
}
|
||||
|
||||
// Point swap node to detached node's parent, children and weight
|
||||
swap->parent = detached->parent;
|
||||
swap->children[kLeft] = detached->children[kLeft];
|
||||
|
||||
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_VERSION_MAJOR 14
|
||||
#define ETL_VERSION_MINOR 35
|
||||
#define ETL_VERSION_PATCH 4
|
||||
#define ETL_VERSION_PATCH 5
|
||||
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "14.35.4",
|
||||
"version": "14.35.5",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "<john.wellbelove@etlcpp.com>"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=14.35.4
|
||||
version=14.35.5
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
14.35.5
|
||||
Bug fix for etl::multiset & etl::multimap erase.
|
||||
|
||||
===============================================================================
|
||||
14.35.4
|
||||
Bug fix for etl::set & etl::map lower_bound.
|
||||
|
||||
@ -1144,5 +1144,40 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_bug)
|
||||
{
|
||||
using Data = etl::multimap<int, int, 10>;
|
||||
|
||||
int keys[10] = { 3, 2, 1, 0, 3, 0, 3, 0, 2, 2 };
|
||||
|
||||
Data data;
|
||||
|
||||
for (int eltNum = 0; eltNum != 10; ++eltNum)
|
||||
{
|
||||
data.insert(Data::value_type(keys[eltNum], eltNum));
|
||||
}
|
||||
|
||||
data.erase(2);
|
||||
|
||||
int prv = INT_MAX;
|
||||
Data::const_reverse_iterator pos;
|
||||
|
||||
bool pass = true;
|
||||
|
||||
for (pos = data.crbegin(); pos != data.crend(); ++pos)
|
||||
{
|
||||
if (pos->first > prv)
|
||||
{
|
||||
pass = false;
|
||||
break;
|
||||
}
|
||||
|
||||
prv = pos->first;
|
||||
}
|
||||
|
||||
CHECK(pass);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1102,5 +1102,40 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_erase_bug)
|
||||
{
|
||||
using Data = etl::multiset<int, 10>;
|
||||
|
||||
int keys[10] = { 3, 2, 1, 0, 3, 0, 3, 0, 2, 2 };
|
||||
|
||||
Data data;
|
||||
|
||||
for (int eltNum = 0; eltNum != 10; ++eltNum)
|
||||
{
|
||||
data.insert(Data::value_type(keys[eltNum]));
|
||||
}
|
||||
|
||||
data.erase(2);
|
||||
|
||||
int prv = INT_MAX;
|
||||
Data::const_reverse_iterator pos;
|
||||
|
||||
bool pass = true;
|
||||
|
||||
for (pos = data.crbegin(); pos != data.crend(); ++pos)
|
||||
{
|
||||
if (*pos > prv)
|
||||
{
|
||||
pass = false;
|
||||
break;
|
||||
}
|
||||
|
||||
prv = *pos;
|
||||
}
|
||||
|
||||
CHECK(pass);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@
|
||||
<UndefinePreprocessorDefinitions>
|
||||
</UndefinePreprocessorDefinitions>
|
||||
<MultiProcessorCompilation>false</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp14</LanguageStandard>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<SupportJustMyCode>false</SupportJustMyCode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -326,6 +326,7 @@
|
||||
<AdditionalIncludeDirectories>../../../unittest-cpp/UnitTest++/;../../include;../../include/etl/c;../../test</AdditionalIncludeDirectories>
|
||||
<UndefinePreprocessorDefinitions>
|
||||
</UndefinePreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user