class PAbstractArray |
This class contains a variable length array of arbitrary memory blocks.
![]() | Construction |
![]() | Overrides from class PObject |
![]() | Overrides from class PContainer |
![]() | New functions for class |
![]() | elementSize Size of an element in bytes |
![]() | theArray Pointer to the allocated block of memory |
![]() | allocatedDynamically Flag indicating the array was allocated on the heap |
Common functions for containers
Run Time Type functions
I/O functions
Comparison functions
This class contains a variable length array of arbitrary memory blocks. These can be anything from individual bytes to large structures. Note that that does not include class objects that require construction or destruction. Elements in this array will not execute the contructors or destructors of objects.An abstract array consists of a linear block of memory sufficient to hold PContainer::GetSize() elements of elementSize bytes each. The memory block itself will atuomatically be resized when required and freed when no more references to it are present.
The PAbstractArray class would very rarely be descended from directly by the user. The PBASEARRAY macro would normally be used to create a class and any new classes descended from that. That will instantiate the template based on PBaseArray or directly declare and define a class (using inline functions) if templates are not being used.
The PBaseArray class or PBASEARRAY macro will define the correctly typed operators for pointer access (operator const T *) and subscript access (operator[]).
If the initial size is zero then no memory is allocated. Note that the internal pointer is set to NULL, not to a pointer to zero bytes of memory. This can be an important distinction when the pointer is obtained via an operator created in the PBASEARRAY macro.
If the initial size is zero then no memory is allocated. Note that the internal pointer is set to NULL, not to a pointer to zero bytes of memory. This can be an important distinction when the pointer is obtained via an operator created in the PBASEARRAY macro.
If the dynamicAllocation parameter is FALSE then the pointer is used directly by the container. It will not be copied to a dynamically allocated buffer. If the SetSize() function is used to change the size of the buffer, the object will be converted to a dynamic form with the contents of the static buffer copied to the allocated buffer.
The default behaviour is to print the class name.
The default behaviour is to do nothing.
If the array sizes are identical then the memcmp() function is used to rank the two arrays.
Any dynamically allocated buffer will be freed.
It is unsafe to assume that the pointer is valid for very long after return from this function. The array may be resized or otherwise changed and the pointer returned invalidated. It should be used for simple calls to atomic functions, or very careful examination of the program logic must be performed.
Note this does nothing and returns FALSE if the target array is not dynamically allocated, or if the two arrays are of base elements of different sizes.
Alphabetic index HTML hierarchy of classes or Java