125 lines
4 KiB
MQL5
125 lines
4 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Dbl.mqh |
|
||
|
|
//| Copyright 2026, Niquel Mendoza |
|
||
|
|
//| https://www.mql5.com |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "Copyright 2026, Niquel Mendoza"
|
||
|
|
#property link "https://www.mql5.com"
|
||
|
|
#property strict
|
||
|
|
|
||
|
|
#ifndef FASTCOLLECTIONSBYLEO_COLHASH_HASH_GENERIC_NUMBER_DBL_MQH
|
||
|
|
#define FASTCOLLECTIONSBYLEO_COLHASH_HASH_GENERIC_NUMBER_DBL_MQH
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#include "Ul.mqh"
|
||
|
|
#include <TSN\\Tables\\Main.mqh>
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
namespace TSN
|
||
|
|
{
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
// Normlaizamos a 0.0 para eviar bgus tipo hash(+0.0) != hash(-0.0)
|
||
|
|
// daod que ambos en la repcis IE.. son diferneies pero el sntandr los trata como iguaels
|
||
|
|
// haremos lo mismo aqui...
|
||
|
|
// la idea es como son igles osea == 0.0 (donde v es - o +) dara true y eso lo nramles a 0.0 de lo contraio a v
|
||
|
|
#define GENERICHASH_NORMALIZE_DBL(v) (v==0.0?0.0:v)
|
||
|
|
|
||
|
|
#define GENERICHHASDBL_CONVERT \
|
||
|
|
TsnBitInterprete bit; \
|
||
|
|
bit.double_value = GENERICHASH_NORMALIZE_DBL(v);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Double |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
class CGenericHash_double : public CGenericHash_eq_simple<double>
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CGenericHash_double() {}
|
||
|
|
~CGenericHash_double() {}
|
||
|
|
|
||
|
|
//---
|
||
|
|
static ulong Hash(const double v)
|
||
|
|
{
|
||
|
|
GENERICHHASDBL_CONVERT
|
||
|
|
GENERICHHASH_SPLITMIX(bit.ulong_value)
|
||
|
|
return bit.ulong_value;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
class CGenericHash_double_fmix : public CGenericHash_eq_simple<double>
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CGenericHash_double_fmix() {}
|
||
|
|
~CGenericHash_double_fmix() {}
|
||
|
|
|
||
|
|
//---
|
||
|
|
static ulong Hash(const double v)
|
||
|
|
{
|
||
|
|
GENERICHHASDBL_CONVERT
|
||
|
|
GENERICHHASH_FMIX(bit.ulong_value)
|
||
|
|
return bit.ulong_value;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
class CGenericHash_double_fibbo : public CGenericHash_eq_simple<double>
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CGenericHash_double_fibbo() {}
|
||
|
|
~CGenericHash_double_fibbo() {}
|
||
|
|
|
||
|
|
//---
|
||
|
|
static ulong Hash(const double v)
|
||
|
|
{
|
||
|
|
GENERICHHASDBL_CONVERT
|
||
|
|
return bit.ulong_value * 0x9E3779B97F4A7C15;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
class CGenericHash_double_fibbo_plus : public CGenericHash_eq_simple<double>
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CGenericHash_double_fibbo_plus() {}
|
||
|
|
~CGenericHash_double_fibbo_plus() {}
|
||
|
|
|
||
|
|
//---
|
||
|
|
static ulong Hash(const double v)
|
||
|
|
{
|
||
|
|
GENERICHHASDBL_CONVERT
|
||
|
|
GENERICHHASH_FIBBO_PLUS(bit.ulong_value)
|
||
|
|
return bit.ulong_value;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
class CGenericHash_double_murmur : public CGenericHash_eq_simple<double>
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CGenericHash_double_murmur() {}
|
||
|
|
~CGenericHash_double_murmur() {}
|
||
|
|
|
||
|
|
//---
|
||
|
|
static ulong Hash(const double v)
|
||
|
|
{
|
||
|
|
GENERICHHASDBL_CONVERT
|
||
|
|
GENERICHHASH_FIBBO_MURMUR(bit.ulong_value)
|
||
|
|
return bit.ulong_value;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#endif // FASTCOLLECTIONSBYLEO_COLHASH_HASH_GENERIC_NUMBER_DBL_MQH
|