forked from nique_372/MQLArticles
64 lines
2.2 KiB
MQL5
64 lines
2.2 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Hash.mqh |
|
|
//| Copyright 2026, Niquel Mendoza |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2026, Niquel Mendoza"
|
|
#property link "https://www.mql5.com"
|
|
#property strict
|
|
|
|
#ifndef MQLARTICLES_UTILS_BITS_HASH_MQH
|
|
#define MQLARTICLES_UTILS_BITS_HASH_MQH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "BitFastBuffer.mqh"
|
|
#include <TSN\\Tables\\AllHashes.mqh>
|
|
#include <TSN\\GCol\\HashMap.mqh>
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
namespace TSN
|
|
{
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CGenericHash_CBitBuffer
|
|
{
|
|
public:
|
|
CGenericHash_CBitBuffer() {}
|
|
~CGenericHash_CBitBuffer() {}
|
|
|
|
//---
|
|
static ulong Hash(const CBitBuffer &v)
|
|
{
|
|
return TSN::XUL::XXH64(v.m_bits, v.m_s + 1, 0ULL);
|
|
}
|
|
|
|
//---
|
|
static bool Eq(const CBitBuffer &a, const CBitBuffer &b)
|
|
{
|
|
if(a.m_s != b.m_s)
|
|
return false;
|
|
// igual dado que el array en si size real es ms + (w > 0)
|
|
// ms reprensta la escritura actual
|
|
for(int i = 0; i <= a.m_s; i++)
|
|
if(a.m_bits[i] != b.m_bits[i])
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
//---
|
|
template <typename TValue>
|
|
static void Assing(CHashMapFastInternalPar<CBitBuffer, TValue>& a, CHashMapFastInternalPar<CBitBuffer, TValue>& b)
|
|
{
|
|
a.hash = b.hash;
|
|
a.value = b.value;
|
|
a.key.RobarDe(b.key);
|
|
}
|
|
};
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
#endif // MQLARTICLES_UTILS_BITS_HASH_MQH
|