Imagine that we have an array of a million unique identifiers, such as a thousand orders. How can we check if in this thousand of orders, there is one order with number N? If we use one of the generic classes, this task can be accomplished almost instantly, in a constant amount of time, which doesn't depend on the number of elements searched for.
Not familiar with the topic at all. But the highlighted sounds illogical.
Unfortunately, the library has just been released and is still raw. I've already found the first error in it (I'll highlight errors with a highlighter):
Error in CSortedSet:
//+------------------------------------------------------------------+ //| Class CSortedSet<T>. | //| Usage: Represents a collection of objects that is maintained in | //| sorted order. | //+------------------------------------------------------------------+ template<typename T> class CSortedSet: public ISet<T> { ... bool TryGetMin(T &min) { return(m_tree.TryGetMin(min)); } bool TryGetMax(T &max) { return(m_tree.TryGetMin(max)); } ... }
TryGetMax method returns not the maximum but the minimum element, as well as TryGetMin
... But the highlighted sounds illogical.
Why is that?
Why is that?
Make hashes, sort them in ascending order. But there will be a search anyway.
Not familiar with the topic at all. But the highlighted sounds illogical.
Making hashes...
Let's define the terminology. Nothing is instantaneous. Every operation takes time. When I say instantaneous, I'm simplifying it so that novice programmers understand me. Strictly speaking, there are several classes of complexity, the main ones we'll deal with are the following:
- Constant complexity cO(1).
- Logarithmic: cO(log n).
- Linear: cO (n).
- Algorithms that require non linear execution time.
I deliberately introduced the c sign - as a certain constant that occurs when calculating the hash, and other technical manipulations. But in this case, the discussion about optimization of constantc is off topic of this thread. We are interested here only in generic classes and their application in practice.
Make hashes, sort them in ascending order. But the search will be in any case.
Average time O(1) worst O(n) and the perfomance is highly dependent on the hash.
+
p.s. To illustrate, here's an example where this same perfomance will drop to O(n) if you don't work with CHashMap correctly.
I wrote it very clearly
Forum on trading, automated trading systems and trading strategies testing
Generic Classes Library - bugs, description, questions, peculiarities of usage and suggestions
fxsaber, 2017.12.07 12:43
The highlighted sounds illogical.
Look at what is highlighted.
I suggest to simplify the names - make them more logical. For example, is CArrayList an Array or List in mql5 the implementation of both?
This all leads to questions and confusion. IMHO, we should use stl instead of C# or Java. Or remove C in front of it then, let it just be ArrayList.
If you make normal names:
- readability will improve many times over.
- you will have your own specific mql5 style.
- newbies will be able to immediately navigate the code (because stl is included in the standard)
...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
As of December 6, 2017, the standard MetaTrader 5 delivery set includes the so-called Generic classes, which implement efficient algorithms for data storage and extraction. This branch was created to describe these classes, examples of working with them, as well as for suggestions on how to improve their work.
What is Generic? Generic is a special template classes that can store custom data types. In this case, the type is identified at the time of compilation, which achieves high performance.
Why Generic? Typically, novice programmers are familiar with only one type of collection: an array. But there are many tasks where working with arrays is ineffective. Imagine that we have an array consisting of a million unique identifiers, for example, a thousand orders. How can we check whether in this thousand of orders, there is one order with number N? If we use one of the generic classes, this task can be accomplished almost immediately, in a constant amount of time, which does not depend on the number of elements to be searched among. There are other problems where the correct algorithm from the generic collection can be faster than the algorithm invented by the programmer.
Generic algorithms. Below is a table of generic classes, with a brief description of what they do:
We will go on later and look at the implementation features of these classes.