From 02d84af90762ee6874ef76b52be0b61741c627ed Mon Sep 17 00:00:00 2001 From: Metehan Tuncbilek Date: Mon, 23 Sep 2024 17:00:07 +0300 Subject: [PATCH] -first draft of BinSearchArrayMap --- openVulkanoCpp/Data/Containers/BinSearchArrayMap.hpp | 7 ++++--- tests/BinSearchArrayMapTest.cpp | 3 ++- tests/MemFileTests.cpp | 3 --- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/openVulkanoCpp/Data/Containers/BinSearchArrayMap.hpp b/openVulkanoCpp/Data/Containers/BinSearchArrayMap.hpp index ee14317..cf8629b 100644 --- a/openVulkanoCpp/Data/Containers/BinSearchArrayMap.hpp +++ b/openVulkanoCpp/Data/Containers/BinSearchArrayMap.hpp @@ -33,7 +33,7 @@ namespace OpenVulkano throw std::runtime_error("Key cannot be lesser than the last used key."); } - template void Emplace(K key, Args... args) + template void Emplace(K key, Args... args) { // Check if the key is bigger than the last element if (m_data.empty() || key > m_data.back().first) @@ -45,7 +45,7 @@ namespace OpenVulkano throw std::runtime_error("Key cannot be lesser than the last used key."); } - void Remove(K key) noexcept + void Remove(K key) noexcept { auto it = std::lower_bound(m_data.begin(), m_data.end(), key, [](const auto& pair, const K& key) { return pair.first < key; }); @@ -70,7 +70,8 @@ namespace OpenVulkano return it->second; } - V& Get(K key) noexcept { + V& Get(K key) noexcept + { auto it = std::lower_bound(m_data.begin(), m_data.end(), key, [](const auto& pair, const K& key) { return pair.first < key; }); diff --git a/tests/BinSearchArrayMapTest.cpp b/tests/BinSearchArrayMapTest.cpp index ea5e4e5..8661947 100644 --- a/tests/BinSearchArrayMapTest.cpp +++ b/tests/BinSearchArrayMapTest.cpp @@ -12,6 +12,7 @@ #include #include "Data/Containers/BinSearchArrayMap.hpp" +#include "Data/Containers/StableVector.hpp" using namespace OpenVulkano; @@ -26,7 +27,6 @@ TEST_CASE("BinSearchArrayMap") auto wtf = std::lower_bound(data.begin(), data.end(), 10, [](const auto& pair, const int& key) { return pair.first < key; }); - auto test = *wtf; REQUIRE(test.first == 10); REQUIRE(test.second == "Five"); @@ -39,4 +39,5 @@ TEST_CASE("BinSearchArrayMap") map.Insert(10, "Five"); REQUIRE(map[6] == "Three"); + REQUIRE(map[10] == "Five"); } diff --git a/tests/MemFileTests.cpp b/tests/MemFileTests.cpp index 117ffa5..3cb433e 100644 --- a/tests/MemFileTests.cpp +++ b/tests/MemFileTests.cpp @@ -95,7 +95,6 @@ TEST_CASE("MemMappedFileWrite") OpenVulkano::MemMappedFileWriteHelper::USE_CURRENT_FILE_SIZE); REQUIRE(helper.Data() != nullptr); std::string testData((char*) helper.Data()); - printf("size: %llu", helper.Size()); helper.Close(); std::ifstream file(path, std::ios::binary); @@ -112,8 +111,6 @@ TEST_CASE("MemMappedFileWrite") } REQUIRE(streamData.size() == testData.size()); - - printf("helper size: %llu\n", helper.Size()); } SECTION("Actual Size")