Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Libraries | CHashArrayStringString

An include file contains a set of classes demonstrating one of methods of organizing lines hash array with a string key.

An example of usage:

#include <HashArray.mqh>

void OnStart()
  {
   CHashArrayStringString Hash;
   Hash.Put("k1", "v1");
   Hash.Put("k2", "v2");

   Hash["k3"] = "v3";
   Hash["k2"] = "vv2";

   string t1 = Hash["k1"].value;
   string t2 = Hash["k2"].value;
   string t3 = Hash["k3"].value;

   Alert("k1=",t1);
   Alert("k2=",t2);
   Alert("k3=",t3);
  }

The result:

MetaTrader Experts, Indicators, Scripts and Libraries

Performance test:

An include file contains a set of classes demonstrating one of methods of organizing lines hash array with a string key.

#include <HashArray.mqh>
void OnStart()
{
   CHashArrayStringString Hash();
   uint StartTime=GetTickCount();
   for(int n=0; n<10000; n++)
   {
      Hash["key"+IntegerToString(n)] = "trash";
   }
   uint timeTotal = GetTickCount() - StartTime;
   Alert("add 10k elements in ", IntegerToString(timeTotal), " ms");
   
}
add 10k elements in 31 ms

MetaTrader Experts, Indicators, Scripts and Libraries

7047

Best MetaTrader Indicators + Profitable Expert Advisors