commit 1.2

This commit is contained in:
2026-09-09 00:52:00 -03:00
parent 572b5c7bd5
commit f30f25a91e
10 changed files with 436 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
export module map;
import std;
namespace brc {
export struct entry {
std::uint64_t key_hash = 0;
const char* key_ptr = nullptr; // 8, 8
std::int64_t total = 0; // 8, 26
std::int32_t min = std::numeric_limits<std::int32_t>::max(); // 4, 12
std::int32_t max = std::numeric_limits<std::int32_t>::min(); // 4, 16
std::uint32_t count = 0; // 4, 30
std::uint16_t key_len = 0; // 2, 32
};
export class map {
private:
std::size_t entry_count;
std::unique_ptr<entry[]> entries;
[[nodiscard]] static std::uint64_t get_key(std::string_view city) noexcept;
[[nodiscard]] std::uint64_t get_index(std::string_view city) const noexcept;
public:
explicit map(std::size_t entry_count);
void insert(std::string_view city, std::int32_t measurement);
[[nodiscard]] entry& operator[](std::string_view city);
void merge_against(const map& other);
[[nodiscard]] std::vector<entry> collapse() const noexcept;
};
} // namespace brc