stable vector fix for algorithm. Still no correct Iterator.

This commit is contained in:
Metehan Tuncbilek
2024-10-08 07:20:41 +03:00
parent eb2ca2ff5a
commit 7b40d001ec
4 changed files with 316 additions and 266 deletions

View File

@@ -45,69 +45,43 @@ TEST_CASE("BinSearchArrayMap With Default")
map.Remove(16);
map.Remove(23);
map.Remove(48);
REQUIRE(map[49] == "49");
printf("ARRAY WITH DEFAULT\n");
for (int i = 0; i < 50; i++)
{
if (map.Contains(i))
{
printf("index: %d, value: %s\n", i, map[i].c_str());
}
else
{
printf("index: %d, value: %s\n", i, "EMPTY");
}
}
}
}
//TEST_CASE("BinSearchArrayMap With StableVector")
//{
// SECTION("Insert")
// {
// BinSearchArrayMap<int, std::string, std::pair, StableVector> map;
//
// for (int i = 0; i < 50; i++)
// {
// map.Insert(i, std::to_string(i));
// }
//
// REQUIRE(map.Size() == 50);
// REQUIRE(map.Get(16) == "16");
// REQUIRE(map.Get(23) == "23");
// REQUIRE(map.Get(48) == "48");
// }
//
// SECTION("Remove")
// {
// BinSearchArrayMap<int, std::string, std::pair, StableVector> map;
//
// for (int i = 0; i < 50; i++)
// {
// map.Insert(i, std::to_string(i));
// }
//
// map.Remove(16);
// map.Remove(23);
//
// if (map.Contains(49))
// {
// printf("index: %d, value: %s\n", 49, map[49].c_str());
// }
//
// printf("ARRAY WITH STABLE VECTOR\n");
// for (int i = 0; i < 50; i++)
// {
// if (map.Contains(i))
// {
// printf("index: %d, value: %s\n", i, map[i].c_str());
// }
// else
// {
// printf("index: %d, value: %s\n", i, "EMPTY");
// }
// }
// }
//}
TEST_CASE("BinSearchArrayMap With StableVector")
{
SECTION("Insert")
{
BinSearchArrayMap<int, std::string, std::pair, StableVector> map;
for (int i = 0; i < 50; i++)
{
map.Insert(i, std::to_string(i));
}
REQUIRE(map.Size() == 50);
REQUIRE(map.Get(16) == "16");
REQUIRE(map.Get(23) == "23");
REQUIRE(map.Get(48) == "48");
}
SECTION("Remove")
{
BinSearchArrayMap<int, std::string, std::pair, StableVector> map;
for (int i = 0; i < 50; i++)
{
map.Insert(i, std::to_string(i));
}
map.Remove(16);
map.Remove(23);
map.Remove(48);
printf("ARRAY WITH STABLE VECTOR\n");
for (int i = 0; i < 50; i++)
{
printf("index: %d, value: %s\n", i, map[i].c_str());
}
}
}