geforkt von nique_372/TSNStd
75 Zeilen
2,8 KiB
MQL5
75 Zeilen
2,8 KiB
MQL5
//+------------------------------------------------------------------+
| |
//| Simple.mqh |
| |
//| Copyright 2026, Niquel Mendoza. |
| |
//| https://www.mql5.com |
| |
//+------------------------------------------------------------------+
| |
#property copyright "Copyright 2026, Niquel Mendoza."
| |
#property link "https://www.mql5.com"
| |
#property strict
| |
| |
#ifndef TSNSTD_SRC_SORT_GENERIC_SIMPLE_MQH
| |
#define TSNSTD_SRC_SORT_GENERIC_SIMPLE_MQH
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#include "..\\Base\\Sort.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
// Por defecto simple..
| |
#define TsnSort(arr, lo, hi, type) CTsnSort::Sort<type, CGenericUtilsSort_##type>(arr, (lo), (hi))
| |
// Version custom espeicia el "TBase"
| |
#define TsnSortP(arr, lo, hi, type, BASE) CTsnSort::Sort<type, CGenericUtilsSort_##BASE>(arr, (lo), (hi))
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
class CGenericUtilsSort_Simple
| |
{
| |
public:
| |
CGenericUtilsSort_Simple(void) {}
| |
~CGenericUtilsSort_Simple(void) {}
| |
| |
//---
| |
template<typename TValue>
| |
static __forceinline bool Less(const TValue a, const TValue b) { return a < b; }
| |
template<typename TValue>
| |
static void Swap(TValue& a, TValue& b)
| |
{
| |
const TValue temp = a;
| |
a = b;
| |
b = temp;
| |
}
| |
};
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#define TSNSORT_MAKE_CLASS_SIMPLE(TYPE) \
| |
class CGenericUtilsSort_##TYPE : public CGenericUtilsSort_Simple \
| |
{ \
| |
public: \
| |
CGenericUtilsSort_##TYPE(void) {} \
| |
~CGenericUtilsSort_##TYPE(void) {} \
| |
};
| |
| |
//---
| |
TSNSORT_MAKE_CLASS_SIMPLE(int)
| |
TSNSORT_MAKE_CLASS_SIMPLE(long)
| |
TSNSORT_MAKE_CLASS_SIMPLE(char)
| |
TSNSORT_MAKE_CLASS_SIMPLE(short)
| |
TSNSORT_MAKE_CLASS_SIMPLE(uint)
| |
TSNSORT_MAKE_CLASS_SIMPLE(ulong)
| |
TSNSORT_MAKE_CLASS_SIMPLE(uchar)
| |
TSNSORT_MAKE_CLASS_SIMPLE(ushort)
| |
TSNSORT_MAKE_CLASS_SIMPLE(float)
| |
TSNSORT_MAKE_CLASS_SIMPLE(double)
| |
TSNSORT_MAKE_CLASS_SIMPLE(datetime)
| |
TSNSORT_MAKE_CLASS_SIMPLE(color)
| |
| |
| |
| |
//+------------------------------------------------------------------+
| |
#endif // TSNSTD_SRC_SORT_GENERIC_SIMPLE_MQH
|