1-
2- struct Person {
3- const int32_t Age;
4- const std::u32string_view Name;
5- const Person* Other;
6-
7- Person(const int32_t age, const std::u32string_view name, const Person* other) : Age(age), Name(name), Other(other) { }
8- };
9-
10- // This file is auto-generated. Do not edit manually.
11- // Structure: HashTable (HashTableChain)
1+ // This file is auto-generated. Do not edit manually.
2+ // Structure: HashTable
123#pragma once
134#include <array>
145#include <cstdint>
156#include <limits>
167#include <string_view>
178
18- class HashTableChainStructure_Int32_3 final
9+ struct Person {
10+ int32_t age;
11+ std::u32string_view name;
12+ const Person* other;
13+
14+ Person(const int32_t age, const std::u32string_view name, const Person* other) : age(age), name(name), other(other) { }
15+ };
16+ class HashTableStructure_Int32_3 final
1917{
2018 struct e
2119 {
22-
23- int8_t next;
2420 int32_t key;
25-
26- e(const int8_t next, const int32_t key)
27- : next(next), key(key) {}
21+ int8_t next;
22+
23+ const Person* value;
24+ e(const int8_t next, const int32_t key, const Person* value)
25+ : next(next), key(key), value(value) {}
2826 };
2927
3028 static constexpr std::array<int8_t, 3> buckets = {
3129 3, 1, 2
3230 };
3331
3432 inline static const std::array<e, 3> entries = {
35- e(-1, 1) , e(-1, 2) , e(-1, 3)
33+ e(-1, 1, new Person(1, U"Bob", new Person(4, U"Anna", nullptr))) , e(-1, 2, new Person(2, U"Billy", nullptr)) , e(-1, 3, new Person(3, U"Bibi", nullptr) )
3634 };
3735
3836 static constexpr uint64_t get_hash(const int32_t value) noexcept
@@ -53,18 +51,16 @@ public:
5351
5452 while (i >= 0)
5553 {
56- const auto& [next, key1] = entries[i];
54+ const auto& entry = entries[i];
5755
58- if (key1 == key)
56+ if (entry.key == key)
5957 return true;
6058
61- i = next;
59+ i = entry. next;
6260 }
6361
6462 return false;
6563 }
66- static std::array<Person*, 3> values;
67-
6864 [[nodiscard]]
6965 static bool try_lookup(const int32_t key, const Person*& value) noexcept
7066 {
@@ -77,12 +73,15 @@ public:
7773
7874 while (i >= 0)
7975 {
80- const auto& [next, key1] = entries[i];
76+ const auto& entry = entries[i];
8177
82- if (key1 == key)
78+ if (entry.key == key)
79+ {
80+ value = entry.value;
8381 return true;
82+ }
8483
85- i = next;
84+ i = entry. next;
8685 }
8786
8887 value = nullptr;
@@ -94,15 +93,9 @@ public:
9493 static constexpr int32_t max_key = 3;
9594
9695public:
97- HashTableChainStructure_Int32_3() = delete;
98- HashTableChainStructure_Int32_3(const HashTableChainStructure_Int32_3&) = delete;
99- HashTableChainStructure_Int32_3& operator=(const HashTableChainStructure_Int32_3&) = delete;
100- HashTableChainStructure_Int32_3(HashTableChainStructure_Int32_3&&) = delete;
101- HashTableChainStructure_Int32_3& operator=(HashTableChainStructure_Int32_3&&) = delete;
102- };
103- std::array<Person*, 3> HashTableChainStructure_Int32_3::values = {
104- new Person(1, U"Bob", new Person(4, U"Anna", nullptr)),
105- new Person(2, U"Billy", nullptr),
106- new Person(3, U"Bibi", nullptr),
107-
108- };
96+ HashTableStructure_Int32_3() = delete;
97+ HashTableStructure_Int32_3(const HashTableStructure_Int32_3&) = delete;
98+ HashTableStructure_Int32_3& operator=(const HashTableStructure_Int32_3&) = delete;
99+ HashTableStructure_Int32_3(HashTableStructure_Int32_3&&) = delete;
100+ HashTableStructure_Int32_3& operator=(HashTableStructure_Int32_3&&) = delete;
101+ };
0 commit comments