2026-06-28 19:22:20 -05:00 | | | //+-------------------------------------------------------------------+
|
| | | //| Include generado por la herramienta PerfectHash SimPHash |
|
| | | //| Esta heramienta forma parte del ecositema TSN |
|
| | | //| Repositorio: https://forge.mql5.io/nique_372/SimPHash |
|
| | | //+-------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2026, Niquel Mendoza"
|
| | | #property link "https://www.mql5.com/"
|
2026-06-28 10:43:20 -05:00 | | | #property strict
|
| | |
|
2026-06-28 19:22:20 -05:00 | | |
|
2026-06-28 10:43:20 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include <TSN/Tables/AllHashes.mqh>
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-28 22:02:48 -05:00 | | | #define TABLE_SIZE_FINAL (8ULL)
|
| | | #define TABLE_SIZE_FINAL_LAST (7ULL)
|
2026-06-28 19:22:20 -05:00 | | | #define TABLE_SIZE_BUCKETS (1ULL)
|
2026-07-28 22:02:48 -05:00 | | | #define TABLE_SIZE_BUCKETS_LAST (0ULL)
|
2026-06-28 10:43:20 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | namespace TSN
|
| | | {
|
2026-06-28 19:22:20 -05:00 | | | const ulong g_table_test_seeds[TABLE_SIZE_BUCKETS] =
|
2026-06-28 10:43:20 -05:00 | | | {
|
2026-07-28 22:02:48 -05:00 | | | 5ULL
|
2026-06-28 10:43:20 -05:00 | | | };
|
| | |
|
2026-06-28 19:22:20 -05:00 | | | const ulong g_table_test_hashes[TABLE_SIZE_FINAL] =
|
2026-06-28 10:43:20 -05:00 | | | {
|
2026-07-28 22:02:48 -05:00 | | | 0ULL, // invalid
|
| | | 16162063474616199333ULL, // DOS
|
| | | 0ULL, // invalid
|
2026-06-28 19:22:20 -05:00 | | | 889639972767027087ULL, // CINCO
|
| | | 0ULL, // invalid
|
2026-07-28 22:02:48 -05:00 | | | 7082449285793839247ULL, // UNO
|
| | | 1578112930777586163ULL, // CUATRO
|
| | | 8077034385145237811ULL
|
2026-06-28 10:43:20 -05:00 | | | };
|
| | |
|
| | | const long g_table_test_values[TABLE_SIZE_FINAL] =
|
| | | {
|
2026-07-28 22:02:48 -05:00 | | | -1,
|
| | | 2, // DOS
|
| | | -1,
|
2026-06-28 19:22:20 -05:00 | | | 5, // CINCO
|
| | | -1,
|
2026-07-28 22:02:48 -05:00 | | | 1, // UNO
|
| | | 4, // CUATRO
|
| | | 3 // TRES
|
2026-06-28 10:43:20 -05:00 | | | };
|
| | |
|
2026-07-28 11:34:23 -05:00 | | | long HashCustom(const string key)
|
2026-06-28 10:43:20 -05:00 | | | {
|
| | | //---
|
| | | const int len = StringLen(key);
|
2026-06-28 19:22:20 -05:00 | | | ulong key_hash = 14695981039346656037ULL;
|
| | | FNV1a_64_AsM_Str(key, len, key_hash, 1099511628211ULL)
|
2026-06-28 10:43:20 -05:00 | | |
|
2026-07-28 22:02:48 -05:00 | | | const int seed_index = int(key_hash & TABLE_SIZE_BUCKETS_LAST);
|
2026-06-28 19:22:20 -05:00 | | | //---
|
2026-06-28 10:43:20 -05:00 | | | ulong h = key_hash ^ g_table_test_seeds[seed_index];
|
| | | h ^= h >> 16;
|
| | | h *= 0x45d9f3b37197344d;
|
| | | h ^= h >> 16;
|
| | | h *= 0x45d9f3b37197344d;
|
| | | h ^= h >> 16;
|
| | |
|
2026-07-28 22:02:48 -05:00 | | | const int fi = int(h & TABLE_SIZE_FINAL_LAST);
|
2026-06-28 10:43:20 -05:00 | | | return g_table_test_hashes[fi] == key_hash ? g_table_test_values[fi] : -1;
|
| | | }
|
2026-07-27 16:22:17 -05:00 | | |
|
| | | long HashCustom(const ulong key_hash)
|
| | | {
|
2026-07-28 22:02:48 -05:00 | | | const int seed_index = int(key_hash & TABLE_SIZE_BUCKETS_LAST);
|
2026-07-27 16:22:17 -05:00 | | | //---
|
| | | ulong h = key_hash ^ g_table_test_seeds[seed_index];
|
| | | h ^= h >> 16;
|
| | | h *= 0x45d9f3b37197344d;
|
| | | h ^= h >> 16;
|
| | | h *= 0x45d9f3b37197344d;
|
| | | h ^= h >> 16;
|
| | |
|
2026-07-28 22:02:48 -05:00 | | | const int fi = int(h & TABLE_SIZE_FINAL_LAST);
|
2026-07-27 16:22:17 -05:00 | | | return g_table_test_hashes[fi] == key_hash ? g_table_test_values[fi] : -1;
|
| | | }
|
2026-06-28 19:22:20 -05:00 | | | }
|