SimPHash/Src/Hash/UL1/SplitMix.mqh

56 lines
2.2 KiB
MQL5
Raw Permalink Normal View History

2026-06-27 21:28:54 -05:00
//+------------------------------------------------------------------+
//| SplitMix.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com/"
#property strict
#ifndef SIMPHASH_SRC_HASH_UL1_SPLITMIX_MQH
#define SIMPHASH_SRC_HASH_UL1_SPLITMIX_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\Def.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CHash1SplitMix : public IHashGeneratorWSeed
{
public:
CHash1SplitMix(void) {}
~CHash1SplitMix(void) {}
ulong Hash(const ulong v, const ulong seed) override final
{
ulong h = v + seed * 0x9e3779b97f4a7c15;
h = (h ^ (h >> 30)) * 0xbf58476d1ce4e5b9;
h = (h ^ (h >> 27)) * 0x94d049bb133111eb;
return h ^ (h >> 31);
}
void BuildString(string& data, const string& table_seeds_name) override final
{
data += "//---\r\n";
data += StringFormat(" ulong h = key_hash + %s[seed_index] * 0x9e3779b97f4a7c15;\r\n", table_seeds_name);
data += " h = (h ^ (h >> 30)) * 0xbf58476d1ce4e5b9;\r\n";
data += " h = (h ^ (h >> 27)) * 0x94d049bb133111eb;\r\n";
data += " h ^= (h >> 31);\r\n";
data += "\r\n";
}
void AddIncludes(string& data) override final
{
// Nada
}
};
}
//+------------------------------------------------------------------+
#endif // SIMPHASH_SRC_HASH_UL1_SPLITMIX_MQH