hash_map.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /**************************************************************************/
  2. /* hash_map.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef HASH_MAP_H
  31. #define HASH_MAP_H
  32. #include "core/math/math_funcs.h"
  33. #include "core/os/memory.h"
  34. #include "core/templates/hashfuncs.h"
  35. #include "core/templates/paged_allocator.h"
  36. #include "core/templates/pair.h"
  37. /**
  38. * A HashMap implementation that uses open addressing with Robin Hood hashing.
  39. * Robin Hood hashing swaps out entries that have a smaller probing distance
  40. * than the to-be-inserted entry, that evens out the average probing distance
  41. * and enables faster lookups. Backward shift deletion is employed to further
  42. * improve the performance and to avoid infinite loops in rare cases.
  43. *
  44. * Keys and values are stored in a double linked list by insertion order. This
  45. * has a slight performance overhead on lookup, which can be mostly compensated
  46. * using a paged allocator if required.
  47. *
  48. * The assignment operator copy the pairs from one map to the other.
  49. */
  50. template <typename TKey, typename TValue>
  51. struct HashMapElement {
  52. HashMapElement *next = nullptr;
  53. HashMapElement *prev = nullptr;
  54. KeyValue<TKey, TValue> data;
  55. HashMapElement() {}
  56. HashMapElement(const TKey &p_key, const TValue &p_value) :
  57. data(p_key, p_value) {}
  58. };
  59. template <typename TKey, typename TValue,
  60. typename Hasher = HashMapHasherDefault,
  61. typename Comparator = HashMapComparatorDefault<TKey>,
  62. typename Allocator = DefaultTypedAllocator<HashMapElement<TKey, TValue>>>
  63. class HashMap {
  64. public:
  65. static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
  66. static constexpr float MAX_OCCUPANCY = 0.75;
  67. static constexpr uint32_t EMPTY_HASH = 0;
  68. private:
  69. Allocator element_alloc;
  70. HashMapElement<TKey, TValue> **elements = nullptr;
  71. uint32_t *hashes = nullptr;
  72. HashMapElement<TKey, TValue> *head_element = nullptr;
  73. HashMapElement<TKey, TValue> *tail_element = nullptr;
  74. uint32_t capacity_index = 0;
  75. uint32_t num_elements = 0;
  76. _FORCE_INLINE_ uint32_t _hash(const TKey &p_key) const {
  77. uint32_t hash = Hasher::hash(p_key);
  78. if (unlikely(hash == EMPTY_HASH)) {
  79. hash = EMPTY_HASH + 1;
  80. }
  81. return hash;
  82. }
  83. static _FORCE_INLINE_ uint32_t _get_probe_length(const uint32_t p_pos, const uint32_t p_hash, const uint32_t p_capacity, const uint64_t p_capacity_inv) {
  84. const uint32_t original_pos = fastmod(p_hash, p_capacity_inv, p_capacity);
  85. return fastmod(p_pos - original_pos + p_capacity, p_capacity_inv, p_capacity);
  86. }
  87. bool _lookup_pos(const TKey &p_key, uint32_t &r_pos) const {
  88. if (elements == nullptr || num_elements == 0) {
  89. return false; // Failed lookups, no elements
  90. }
  91. const uint32_t capacity = hash_table_size_primes[capacity_index];
  92. const uint64_t capacity_inv = hash_table_size_primes_inv[capacity_index];
  93. uint32_t hash = _hash(p_key);
  94. uint32_t pos = fastmod(hash, capacity_inv, capacity);
  95. uint32_t distance = 0;
  96. while (true) {
  97. if (hashes[pos] == EMPTY_HASH) {
  98. return false;
  99. }
  100. if (distance > _get_probe_length(pos, hashes[pos], capacity, capacity_inv)) {
  101. return false;
  102. }
  103. if (hashes[pos] == hash && Comparator::compare(elements[pos]->data.key, p_key)) {
  104. r_pos = pos;
  105. return true;
  106. }
  107. pos = fastmod((pos + 1), capacity_inv, capacity);
  108. distance++;
  109. }
  110. }
  111. void _insert_with_hash(uint32_t p_hash, HashMapElement<TKey, TValue> *p_value) {
  112. const uint32_t capacity = hash_table_size_primes[capacity_index];
  113. const uint64_t capacity_inv = hash_table_size_primes_inv[capacity_index];
  114. uint32_t hash = p_hash;
  115. HashMapElement<TKey, TValue> *value = p_value;
  116. uint32_t distance = 0;
  117. uint32_t pos = fastmod(hash, capacity_inv, capacity);
  118. while (true) {
  119. if (hashes[pos] == EMPTY_HASH) {
  120. elements[pos] = value;
  121. hashes[pos] = hash;
  122. num_elements++;
  123. return;
  124. }
  125. // Not an empty slot, let's check the probing length of the existing one.
  126. uint32_t existing_probe_len = _get_probe_length(pos, hashes[pos], capacity, capacity_inv);
  127. if (existing_probe_len < distance) {
  128. SWAP(hash, hashes[pos]);
  129. SWAP(value, elements[pos]);
  130. distance = existing_probe_len;
  131. }
  132. pos = fastmod((pos + 1), capacity_inv, capacity);
  133. distance++;
  134. }
  135. }
  136. void _resize_and_rehash(uint32_t p_new_capacity_index) {
  137. uint32_t old_capacity = hash_table_size_primes[capacity_index];
  138. // Capacity can't be 0.
  139. capacity_index = MAX((uint32_t)MIN_CAPACITY_INDEX, p_new_capacity_index);
  140. uint32_t capacity = hash_table_size_primes[capacity_index];
  141. HashMapElement<TKey, TValue> **old_elements = elements;
  142. uint32_t *old_hashes = hashes;
  143. num_elements = 0;
  144. hashes = reinterpret_cast<uint32_t *>(Memory::alloc_static(sizeof(uint32_t) * capacity));
  145. elements = reinterpret_cast<HashMapElement<TKey, TValue> **>(Memory::alloc_static(sizeof(HashMapElement<TKey, TValue> *) * capacity));
  146. for (uint32_t i = 0; i < capacity; i++) {
  147. hashes[i] = 0;
  148. elements[i] = nullptr;
  149. }
  150. if (old_capacity == 0) {
  151. // Nothing to do.
  152. return;
  153. }
  154. for (uint32_t i = 0; i < old_capacity; i++) {
  155. if (old_hashes[i] == EMPTY_HASH) {
  156. continue;
  157. }
  158. _insert_with_hash(old_hashes[i], old_elements[i]);
  159. }
  160. Memory::free_static(old_elements);
  161. Memory::free_static(old_hashes);
  162. }
  163. _FORCE_INLINE_ HashMapElement<TKey, TValue> *_insert(const TKey &p_key, const TValue &p_value, bool p_front_insert = false) {
  164. uint32_t capacity = hash_table_size_primes[capacity_index];
  165. if (unlikely(elements == nullptr)) {
  166. // Allocate on demand to save memory.
  167. hashes = reinterpret_cast<uint32_t *>(Memory::alloc_static(sizeof(uint32_t) * capacity));
  168. elements = reinterpret_cast<HashMapElement<TKey, TValue> **>(Memory::alloc_static(sizeof(HashMapElement<TKey, TValue> *) * capacity));
  169. for (uint32_t i = 0; i < capacity; i++) {
  170. hashes[i] = EMPTY_HASH;
  171. elements[i] = nullptr;
  172. }
  173. }
  174. uint32_t pos = 0;
  175. bool exists = _lookup_pos(p_key, pos);
  176. if (exists) {
  177. elements[pos]->data.value = p_value;
  178. return elements[pos];
  179. } else {
  180. if (num_elements + 1 > MAX_OCCUPANCY * capacity) {
  181. ERR_FAIL_COND_V_MSG(capacity_index + 1 == HASH_TABLE_SIZE_MAX, nullptr, "Hash table maximum capacity reached, aborting insertion.");
  182. _resize_and_rehash(capacity_index + 1);
  183. }
  184. HashMapElement<TKey, TValue> *elem = element_alloc.new_allocation(HashMapElement<TKey, TValue>(p_key, p_value));
  185. if (tail_element == nullptr) {
  186. head_element = elem;
  187. tail_element = elem;
  188. } else if (p_front_insert) {
  189. head_element->prev = elem;
  190. elem->next = head_element;
  191. head_element = elem;
  192. } else {
  193. tail_element->next = elem;
  194. elem->prev = tail_element;
  195. tail_element = elem;
  196. }
  197. uint32_t hash = _hash(p_key);
  198. _insert_with_hash(hash, elem);
  199. return elem;
  200. }
  201. }
  202. public:
  203. _FORCE_INLINE_ uint32_t get_capacity() const { return hash_table_size_primes[capacity_index]; }
  204. _FORCE_INLINE_ uint32_t size() const { return num_elements; }
  205. /* Standard Godot Container API */
  206. bool is_empty() const {
  207. return num_elements == 0;
  208. }
  209. void clear() {
  210. if (elements == nullptr || num_elements == 0) {
  211. return;
  212. }
  213. uint32_t capacity = hash_table_size_primes[capacity_index];
  214. for (uint32_t i = 0; i < capacity; i++) {
  215. if (hashes[i] == EMPTY_HASH) {
  216. continue;
  217. }
  218. hashes[i] = EMPTY_HASH;
  219. element_alloc.delete_allocation(elements[i]);
  220. elements[i] = nullptr;
  221. }
  222. tail_element = nullptr;
  223. head_element = nullptr;
  224. num_elements = 0;
  225. }
  226. TValue &get(const TKey &p_key) {
  227. uint32_t pos = 0;
  228. bool exists = _lookup_pos(p_key, pos);
  229. CRASH_COND_MSG(!exists, "HashMap key not found.");
  230. return elements[pos]->data.value;
  231. }
  232. const TValue &get(const TKey &p_key) const {
  233. uint32_t pos = 0;
  234. bool exists = _lookup_pos(p_key, pos);
  235. CRASH_COND_MSG(!exists, "HashMap key not found.");
  236. return elements[pos]->data.value;
  237. }
  238. const TValue *getptr(const TKey &p_key) const {
  239. uint32_t pos = 0;
  240. bool exists = _lookup_pos(p_key, pos);
  241. if (exists) {
  242. return &elements[pos]->data.value;
  243. }
  244. return nullptr;
  245. }
  246. TValue *getptr(const TKey &p_key) {
  247. uint32_t pos = 0;
  248. bool exists = _lookup_pos(p_key, pos);
  249. if (exists) {
  250. return &elements[pos]->data.value;
  251. }
  252. return nullptr;
  253. }
  254. _FORCE_INLINE_ bool has(const TKey &p_key) const {
  255. uint32_t _pos = 0;
  256. return _lookup_pos(p_key, _pos);
  257. }
  258. bool erase(const TKey &p_key) {
  259. uint32_t pos = 0;
  260. bool exists = _lookup_pos(p_key, pos);
  261. if (!exists) {
  262. return false;
  263. }
  264. const uint32_t capacity = hash_table_size_primes[capacity_index];
  265. const uint64_t capacity_inv = hash_table_size_primes_inv[capacity_index];
  266. uint32_t next_pos = fastmod((pos + 1), capacity_inv, capacity);
  267. while (hashes[next_pos] != EMPTY_HASH && _get_probe_length(next_pos, hashes[next_pos], capacity, capacity_inv) != 0) {
  268. SWAP(hashes[next_pos], hashes[pos]);
  269. SWAP(elements[next_pos], elements[pos]);
  270. pos = next_pos;
  271. next_pos = fastmod((pos + 1), capacity_inv, capacity);
  272. }
  273. hashes[pos] = EMPTY_HASH;
  274. if (head_element == elements[pos]) {
  275. head_element = elements[pos]->next;
  276. }
  277. if (tail_element == elements[pos]) {
  278. tail_element = elements[pos]->prev;
  279. }
  280. if (elements[pos]->prev) {
  281. elements[pos]->prev->next = elements[pos]->next;
  282. }
  283. if (elements[pos]->next) {
  284. elements[pos]->next->prev = elements[pos]->prev;
  285. }
  286. element_alloc.delete_allocation(elements[pos]);
  287. elements[pos] = nullptr;
  288. num_elements--;
  289. return true;
  290. }
  291. // Replace the key of an entry in-place, without invalidating iterators or changing the entries position during iteration.
  292. // p_old_key must exist in the map and p_new_key must not, unless it is equal to p_old_key.
  293. bool replace_key(const TKey &p_old_key, const TKey &p_new_key) {
  294. if (p_old_key == p_new_key) {
  295. return true;
  296. }
  297. uint32_t pos = 0;
  298. ERR_FAIL_COND_V(_lookup_pos(p_new_key, pos), false);
  299. ERR_FAIL_COND_V(!_lookup_pos(p_old_key, pos), false);
  300. HashMapElement<TKey, TValue> *element = elements[pos];
  301. // Delete the old entries in hashes and elements.
  302. const uint32_t capacity = hash_table_size_primes[capacity_index];
  303. const uint64_t capacity_inv = hash_table_size_primes_inv[capacity_index];
  304. uint32_t next_pos = fastmod((pos + 1), capacity_inv, capacity);
  305. while (hashes[next_pos] != EMPTY_HASH && _get_probe_length(next_pos, hashes[next_pos], capacity, capacity_inv) != 0) {
  306. SWAP(hashes[next_pos], hashes[pos]);
  307. SWAP(elements[next_pos], elements[pos]);
  308. pos = next_pos;
  309. next_pos = fastmod((pos + 1), capacity_inv, capacity);
  310. }
  311. hashes[pos] = EMPTY_HASH;
  312. elements[pos] = nullptr;
  313. // _insert_with_hash will increment this again.
  314. num_elements--;
  315. // Update the HashMapElement with the new key and reinsert it.
  316. const_cast<TKey &>(element->data.key) = p_new_key;
  317. uint32_t hash = _hash(p_new_key);
  318. _insert_with_hash(hash, element);
  319. return true;
  320. }
  321. // Reserves space for a number of elements, useful to avoid many resizes and rehashes.
  322. // If adding a known (possibly large) number of elements at once, must be larger than old capacity.
  323. void reserve(uint32_t p_new_capacity) {
  324. uint32_t new_index = capacity_index;
  325. while (hash_table_size_primes[new_index] < p_new_capacity) {
  326. ERR_FAIL_COND_MSG(new_index + 1 == (uint32_t)HASH_TABLE_SIZE_MAX, nullptr);
  327. new_index++;
  328. }
  329. if (new_index == capacity_index) {
  330. return;
  331. }
  332. if (elements == nullptr) {
  333. capacity_index = new_index;
  334. return; // Unallocated yet.
  335. }
  336. _resize_and_rehash(new_index);
  337. }
  338. /** Iterator API **/
  339. struct ConstIterator {
  340. _FORCE_INLINE_ const KeyValue<TKey, TValue> &operator*() const {
  341. return E->data;
  342. }
  343. _FORCE_INLINE_ const KeyValue<TKey, TValue> *operator->() const { return &E->data; }
  344. _FORCE_INLINE_ ConstIterator &operator++() {
  345. if (E) {
  346. E = E->next;
  347. }
  348. return *this;
  349. }
  350. _FORCE_INLINE_ ConstIterator &operator--() {
  351. if (E) {
  352. E = E->prev;
  353. }
  354. return *this;
  355. }
  356. _FORCE_INLINE_ bool operator==(const ConstIterator &b) const { return E == b.E; }
  357. _FORCE_INLINE_ bool operator!=(const ConstIterator &b) const { return E != b.E; }
  358. _FORCE_INLINE_ explicit operator bool() const {
  359. return E != nullptr;
  360. }
  361. _FORCE_INLINE_ ConstIterator(const HashMapElement<TKey, TValue> *p_E) { E = p_E; }
  362. _FORCE_INLINE_ ConstIterator() {}
  363. _FORCE_INLINE_ ConstIterator(const ConstIterator &p_it) { E = p_it.E; }
  364. _FORCE_INLINE_ void operator=(const ConstIterator &p_it) {
  365. E = p_it.E;
  366. }
  367. private:
  368. const HashMapElement<TKey, TValue> *E = nullptr;
  369. };
  370. struct Iterator {
  371. _FORCE_INLINE_ KeyValue<TKey, TValue> &operator*() const {
  372. return E->data;
  373. }
  374. _FORCE_INLINE_ KeyValue<TKey, TValue> *operator->() const { return &E->data; }
  375. _FORCE_INLINE_ Iterator &operator++() {
  376. if (E) {
  377. E = E->next;
  378. }
  379. return *this;
  380. }
  381. _FORCE_INLINE_ Iterator &operator--() {
  382. if (E) {
  383. E = E->prev;
  384. }
  385. return *this;
  386. }
  387. _FORCE_INLINE_ bool operator==(const Iterator &b) const { return E == b.E; }
  388. _FORCE_INLINE_ bool operator!=(const Iterator &b) const { return E != b.E; }
  389. _FORCE_INLINE_ explicit operator bool() const {
  390. return E != nullptr;
  391. }
  392. _FORCE_INLINE_ Iterator(HashMapElement<TKey, TValue> *p_E) { E = p_E; }
  393. _FORCE_INLINE_ Iterator() {}
  394. _FORCE_INLINE_ Iterator(const Iterator &p_it) { E = p_it.E; }
  395. _FORCE_INLINE_ void operator=(const Iterator &p_it) {
  396. E = p_it.E;
  397. }
  398. operator ConstIterator() const {
  399. return ConstIterator(E);
  400. }
  401. private:
  402. HashMapElement<TKey, TValue> *E = nullptr;
  403. };
  404. _FORCE_INLINE_ Iterator begin() {
  405. return Iterator(head_element);
  406. }
  407. _FORCE_INLINE_ Iterator end() {
  408. return Iterator(nullptr);
  409. }
  410. _FORCE_INLINE_ Iterator last() {
  411. return Iterator(tail_element);
  412. }
  413. _FORCE_INLINE_ Iterator find(const TKey &p_key) {
  414. uint32_t pos = 0;
  415. bool exists = _lookup_pos(p_key, pos);
  416. if (!exists) {
  417. return end();
  418. }
  419. return Iterator(elements[pos]);
  420. }
  421. _FORCE_INLINE_ void remove(const Iterator &p_iter) {
  422. if (p_iter) {
  423. erase(p_iter->key);
  424. }
  425. }
  426. _FORCE_INLINE_ ConstIterator begin() const {
  427. return ConstIterator(head_element);
  428. }
  429. _FORCE_INLINE_ ConstIterator end() const {
  430. return ConstIterator(nullptr);
  431. }
  432. _FORCE_INLINE_ ConstIterator last() const {
  433. return ConstIterator(tail_element);
  434. }
  435. _FORCE_INLINE_ ConstIterator find(const TKey &p_key) const {
  436. uint32_t pos = 0;
  437. bool exists = _lookup_pos(p_key, pos);
  438. if (!exists) {
  439. return end();
  440. }
  441. return ConstIterator(elements[pos]);
  442. }
  443. /* Indexing */
  444. const TValue &operator[](const TKey &p_key) const {
  445. uint32_t pos = 0;
  446. bool exists = _lookup_pos(p_key, pos);
  447. CRASH_COND(!exists);
  448. return elements[pos]->data.value;
  449. }
  450. TValue &operator[](const TKey &p_key) {
  451. uint32_t pos = 0;
  452. bool exists = _lookup_pos(p_key, pos);
  453. if (!exists) {
  454. return _insert(p_key, TValue())->data.value;
  455. } else {
  456. return elements[pos]->data.value;
  457. }
  458. }
  459. /* Insert */
  460. Iterator insert(const TKey &p_key, const TValue &p_value, bool p_front_insert = false) {
  461. return Iterator(_insert(p_key, p_value, p_front_insert));
  462. }
  463. /* Constructors */
  464. HashMap(const HashMap &p_other) {
  465. reserve(hash_table_size_primes[p_other.capacity_index]);
  466. if (p_other.num_elements == 0) {
  467. return;
  468. }
  469. for (const KeyValue<TKey, TValue> &E : p_other) {
  470. insert(E.key, E.value);
  471. }
  472. }
  473. void operator=(const HashMap &p_other) {
  474. if (this == &p_other) {
  475. return; // Ignore self assignment.
  476. }
  477. if (num_elements != 0) {
  478. clear();
  479. }
  480. reserve(hash_table_size_primes[p_other.capacity_index]);
  481. if (p_other.elements == nullptr) {
  482. return; // Nothing to copy.
  483. }
  484. for (const KeyValue<TKey, TValue> &E : p_other) {
  485. insert(E.key, E.value);
  486. }
  487. }
  488. HashMap(uint32_t p_initial_capacity) {
  489. // Capacity can't be 0.
  490. capacity_index = 0;
  491. reserve(p_initial_capacity);
  492. }
  493. HashMap() {
  494. capacity_index = MIN_CAPACITY_INDEX;
  495. }
  496. uint32_t debug_get_hash(uint32_t p_index) {
  497. if (num_elements == 0) {
  498. return 0;
  499. }
  500. ERR_FAIL_INDEX_V(p_index, get_capacity(), 0);
  501. return hashes[p_index];
  502. }
  503. Iterator debug_get_element(uint32_t p_index) {
  504. if (num_elements == 0) {
  505. return Iterator();
  506. }
  507. ERR_FAIL_INDEX_V(p_index, get_capacity(), Iterator());
  508. return Iterator(elements[p_index]);
  509. }
  510. ~HashMap() {
  511. clear();
  512. if (elements != nullptr) {
  513. Memory::free_static(elements);
  514. Memory::free_static(hashes);
  515. }
  516. }
  517. };
  518. #endif // HASH_MAP_H