CArrayObj class is a class of dynamic array of pointers to instances of CObject and his heirs.
Class CArrayObj provides the ability to work with a dynamic array of pointers to instances of CObject and his heirs. This gives the possibility to work as a multidimensional dynamic arrays of primitive data types, and the more difficult for organized data structures.
In the class implemented the ability to add / insert / delete elements in an array, sort array, searching in sorted array. In addition, the implemented methods of work with the file.
There are certain subtleties of the class CArrayObj.
class CArrayObj : public CArray |
#include <Arrays\ArrayObj.mqh> |
Attributes |
|
Gets the flag memory management |
|
Sets the flag memory management |
|
Memory control |
|
Allocates memory to increase the size of the array |
|
Sets a new (smaller) size of the array |
|
Clears the array with a total exemption memory array (not element). |
|
Add methods |
|
Adds an element to the end of the array |
|
Adds an element to the end of the array |
|
Inserts an element in the array to the specified position |
|
Inserts an array of elements from another array with the specified position |
|
Copies the array elements from another array |
|
Update methods |
|
Changes the element at the specified position array |
|
Moves an item from a given position in the array to the specified offset |
|
Delete methods |
|
Gets the element from the specified position and removing it from the array |
|
Removes the element from the specified position array |
|
Deletes a group of elements from the specified position array |
|
Removes all elements of the array without the release of the memory array |
|
Access methods |
|
Gets the element from the specified position array |
|
Compare methods |
|
Compares array with another array |
|
Sorted array operations |
|
Inserts element in a sorted array |
|
Searches for an element equal to the model in sorted array |
|
Searches for an element of more samples in sorted array |
|
Searches for an element less than the sample in the sorted array |
|
Searches for an element greater than or equal to the model in sorted array |
|
Searches for an element less than or equal to the model in sorted array |
|
Finds the first element equal to the model in sorted array |
|
Finds the last element equal to the model in sorted array |
|
Input/output |
|
Saves data array in the file |
|
Loads data array from a file |
|
Gets the type identifier of the array |
Derived classes:
Practical application of arrays are descendants of class CObject (including all classes of the standard library).
For example, consider the options for two-dimensional array:
#include <Arrays\ArrayDouble.mqh> |
The class has a mechanism to control dynamic memory, so be careful when working with elements of the array.
Mechanism of memory management can be switched on / off using the method FreeMode (bool). By default, the mechanism is enabled.
Accordingly, there are two options for dealing with the class CArrayObj:
1. Mechanism of memory management is enabled. (default)
In this case, CArrayObj take responsibility for freeing the memory elements after their removal from the array. In this program the user should not free the array elements.
Example:
int i; |
2. Mechanism of memory management is turned off.
In this case, CArrayObj not otvetstvechaet for freeing the memory elements after their removal from the array. In this program the user must free the array elements.
Example:
int i; |