//+------------------------------------------------------------------+ //| Defines.mqh | //| Copyright 2026, Niquel Mendoza. | //| https://www.mql5.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Niquel Mendoza." #property link "https://www.mql5.com/" #property strict #ifndef PERFECTHASHBYLEO_SRC_DEFINES_MQH #define PERFECTHASHBYLEO_SRC_DEFINES_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // LAYOUT [12bit=NumElByBuckets][20bit=StarIndexBucket][32bit=Pos] //--- #define TSN_PHBL_BIT_START_POS_I (32) #define TSN_PHBL_BIT_START_I_BUCKET (12) #define TSN_PHBL_MASK_COUNT (0xFFF) #define TSN_PHBL_MASK_INDEX_BUCKET (0xFFFFF) //--- #define TSN_PHBL_GET_COUNT(v) int(v & TSN_PHBL_MASK_COUNT) #define TSN_PHBL_GET_INDEX(v) int((v >> TSN_PHBL_BIT_START_I_BUCKET) & TSN_PHBL_MASK_INDEX_BUCKET) #define TSN_PHBL_GET_POS(v) int(v >> TSN_PHBL_BIT_START_POS_I) //--- #define TSN_PHBL_EMPAQUETAR(c, sib, p) (long(c) | long(sib) << TSN_PHBL_BIT_START_I_BUCKET | long(p) << TSN_PHBL_BIT_START_POS_I) //--- #ifndef TSN_PHBL_MAX_SIZE_BUCKETS #define TSN_PHBL_MAX_SIZE_BUCKETS 256 #endif // TSN_PHBL_MAX_SIZE_BUCKETS //--- //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ template interface CPerfectHashHasher { #ifdef TSN_PHBL_DESACTIVE_REF ulong Hash(const TKey v); // key a hash ulong #else ulong Hash(const TKey& v); // key a hash ulong #endif // TSN_PHBL_DESACTIVE_REF }; //+------------------------------------------------------------------+ template interface CPerfectHashHasherWSeed { // key a hash ulong con seed #ifdef TSN_PHBL_DESACTIVE_REF ulong Hash(const TKey v, const ulong seed); #else ulong Hash(const TKey& v, const ulong seed); #endif // TSN_PHBL_DESACTIVE_REF }; } //+------------------------------------------------------------------+ #endif // PERFECTHASHBYLEO_SRC_DEFINES_MQH //+------------------------------------------------------------------+