SimPHash/Src/Hash/UL1/MurMur.mqh

62 lines
2.2 KiB
MQL5
Raw Permalink Normal View History

2026-06-27 21:28:54 -05:00
//+------------------------------------------------------------------+
//| MurMur.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_MURMUR_MQH
#define SIMPHASH_SRC_HASH_UL1_MURMUR_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\Def.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CHash1MurMur : public IHashGeneratorWSeed
{
public:
CHash1MurMur(void) {}
~CHash1MurMur(void) {}
ulong Hash(const ulong v, const ulong seed) override final
{
ulong h = v ^ seed;
h ^= h >> 16;
h *= 0x45d9f3b37197344d;
h ^= h >> 16;
h *= 0x45d9f3b37197344d;
h ^= h >> 16;
return h;
}
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 >> 16;\r\n";
data += " h *= 0x45d9f3b37197344d;\r\n";
data += " h ^= h >> 16;\r\n";
data += " h *= 0x45d9f3b37197344d;\r\n";
data += " h ^= h >> 16;\r\n";
data += "\r\n";
}
void AddIncludes(string& data) override final
{
// Nada
}
};
}
//+------------------------------------------------------------------+
#endif // SIMPHASH_SRC_HASH_UL1_MURMUR_MQH