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
Check out the new article: From Basic to Intermediate: Queues, Lists, and Trees (III).
The ArrayInsert function from the MQL5 library is designed to insert new data into an existing array. So far, so good. However, this function has one particular characteristic: when we insert new data at the end of an existing array, the data is simply copied into the array. Essentially, this is equivalent to using the ArrayCopy function.
However, when we want to add elements to the middle of an existing array or to the beginning of that same array, something different happens. In this case, the ArrayInsert function will allocate a new memory block and then copy some elements into that new block. It then adds the new elements we are inserting into the newly allocated block. Only then will it copy the remaining part of the source array into the allocated block. Consequently, when working with a very large array, execution time can be quite long. However, given the characteristics of modern motherboards and the data bus, the blocks being moved would have to be quite large for the difference to be noticeable. Or, at the very least, we need to perform several insertions for the processing time to become noticeable.
However, in the early days of computing, data processing was not nearly as fast. The data bus was slow, and these memory transfers, even with a small number of elements, took a long time. Thus, engineers and scientists developed a solution to this problem. And that solution was lists. Now let's return to Code 01. Once the list is fully formed, something similar to what is shown below will remain in memory:
Author: CODE X