Generic Class Library - bugs, description, questions, usage and suggestions - page 24

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Question about getting a value from a key. In the library code, this method looks like this
Yes, this code can be misleading because of the non-standard reassignment of i in for.
First we access the sub-array by its index, which may contain our value:i=m_buckets[hash_code%m_capacity];(i.e. i index of the sub-array or value bin).
Then, in the same for, the bin index is turned into the bin item index:i=m_entries[i].next
In fact, the code is written correctly, because in a typical case each sub-array will have on average one item and the loop will again on average be executed only once.
Yes, this code can be misleading because of the non-standard reassignment of i in for.
First, we access a sub-array by its index, which may contain our value:i=m_buckets[hash_code%m_capacity];(i.e. i index of the sub-array or basket of values).
Then, in the same for, the bin index is turned into the bin item index:i=m_entries[i].next
In fact, the code is written correctly because in a typical case each sub-array will contain on average one item and the loop will on average execute only once.
I understand that the loop is made for collisions: to go through the mini-list.
I take it that the loop is made for collisions: to go through a mini-list.
Yes, absolutely right.
Used the template library(CArrayList) to store custom types. The impression is not great. For some convenience I've written macros
Excessive foolproofing in TryGetValue + impossibility to pass classes by value makes use painful.
Tell me, maybe I don't understand something, but if I try to use a construction of this type:
I get an error:
'Option' - objects are passed by reference only ICollection.mqh 14 18
And then there's a whole stack of errors...Tell me, maybe I don't understand something, but if I try to use a construction of this type:
I get an error:
'Option' - objects are passed by reference only ICollection.mqh 14 18
and there's a full stack of errors next...Try it like this:
Try it this way:
Passing/storing pointers to a collection is wrong conceptually.
Passing/storing pointers to a collection is wrong conceptually.
there is no generic for MQL that is even marginally suitable. all of them have serious bugs. use a built-in array, it will give you less headaches.
there is no generic for MQL that is even slightly suitable. all of them have serious bugs. use an embedded array, it will give you less headache.
Well, yes, I've used an array. Why create collections and put them into kodobase if they are only suitable for built-in types?)