2026-07-19 13:23:27 +00:00
|
|
|
|
# FastCollectionsByLeo
|
|
|
|
|
|
|
2026-07-19 08:35:09 -05:00
|
|
|
|
|
|
|
|
|
|
### Generic
|
|
|
|
|
|
### Fast HashMap
|
|
|
|
|
|
```mql5
|
|
|
|
|
|
void OnStart()
|
|
|
|
|
|
{
|
|
|
|
|
|
CHashMapFast(string, int) map;
|
|
|
|
|
|
map.Add("hola", 10);
|
|
|
|
|
|
map.Add("cinco", 10);
|
|
|
|
|
|
map.Add("My key:", 20);
|
|
|
|
|
|
map.Add("Yo: ", 20);
|
|
|
|
|
|
|
|
|
|
|
|
CHashMapFastIterator(string, int) it = map.BeginIteration();
|
|
|
|
|
|
while(it.IsValid())
|
|
|
|
|
|
{
|
|
|
|
|
|
Print(it.Key(), " = ", it.Val());
|
|
|
|
|
|
it.Next();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Hash map benchmarks
|
|
|
|
|
|
- Access test over 100,000 iterations
|
|
|
|
|
|
- Converting `ENUM_TIMEFRAMES` (string) to integer
|
|
|
|
|
|
- Same PC used for all tests
|
|
|
|
|
|
|
|
|
|
|
|
| Class | Time (microseconds, 100,000 iterations) |
|
|
|
|
|
|
|------------------|-------------------------------------------|
|
|
|
|
|
|
| **Perfect Hash** | ~1705 |
|
|
|
|
|
|
| **CHashMapFast** | 1925<32>1949 |
|
|
|
|
|
|
| **CDictSValue** | 2438<33>2466 |
|
|
|
|
|
|
| **CHashMap** | 8750<35>8827 |
|
|
|
|
|
|
| **Linear** | 9818<31>9869 |
|
|
|
|
|
|
|
|
|
|
|
|
> Test in [Final.mq5](./Collections/Test/Final.mq5)
|