SimPHash/Src/Hash/UL1/fmix.mqh
2026-07-28 11:19:10 -05:00

62 lines
2.1 KiB
MQL5

//+------------------------------------------------------------------+
//| fmix.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_FMIX_MQH
#define SIMPHASH_SRC_HASH_UL1_FMIX_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\Def.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CHash1Fmix : public IHashGeneratorWSeed
{
public:
CHash1Fmix(void) {}
~CHash1Fmix(void) {}
ulong Hash(ulong v, const ulong seed) override final
{
v ^= seed;
v ^= v >> 33;
v *= 0xff51afd7ed558ccd;
v ^= v >> 33;
v *= 0xc4ceb9fe1a85ec53;
v ^= v >> 33;
return v;
}
void BuildString(string& data, const string& table_seeds_name) override final
{
data += "//---\r\n";
data += StringFormat(" ulong h = key_hash ^ %s[seed_index];\r\n", table_seeds_name);
data += " h ^= h >> 33;\r\n";
data += " h *= 0xff51afd7ed558ccd\r\n";
data += " h ^= h >> 33;\r\n";
data += " h *= 0xc4ceb9fe1a85ec53;\r\n";
data += " h ^= h >> 33;\r\n";
data += "\r\n";
}
void AddIncludes(string& data) override final
{
// Nada
}
};
}
#endif // SIMPHASH_SRC_HASH_UL1_FMIX_MQH