/// Common library Dynamic Object array template class
/**
* General Library version 4.0 <br>
* A Dynamic Object array template class is defined here. This array is suitable for objects that cannot be moved or objects that contain pointers or references.
* The feature is that, unlike XArray, adjusting the array capacity will change the address of all array elements.
* @ Author zdhsoft (Zhu Donghua)
* @ Version 4.0
* @ Date 2008-03-01
* @ File xobjectarray. h
*/
# Ifndef _ X_OBJECT_ARRAY_H _
# Define _ X_OBJECT_ARRAY_H _
# Include <xarray. h>
Namespace zdh
{
/// Dynamic Object Array
Template <class T>
Class XObjectArray
{
Public:
Typedef T ElementType;
Typedef ElementType * PElementType;
/// Default constructor
XObjectArray ()
{}
/// Constructor that specifies the number of initial elements
/**
@ Param [in] aInitLength initializes the size of the array
*/
XObjectArray (XInt aInitLength)
{
If (aInitLength> 0)
{
InitLength (aInitLength );
}
}
/// Constructor that specifies the number of initial elements and default element values
/**
@ Param [in] aInitLength initializes the size of the array
@ Param [in] aDefault initialize the default value of the array element
*/
XObjectArray (XInt aInitLength, const T & aDefault)
{
If (aInitLength> 0)
{
InitLength (aInitLength, aDefault );
}
}
/// Default copy constructor
XObjectArray (const XObjectArray <T> & v );
/// Constructor that specifies the size and initial element pointer
XObjectArray (const T * pData, XInt aSize, XInt aStartIndex = 0 );
/// Specify the size and the constructor of the initial element array
XObjectArray (const XObjectArray <T> & v, XInt aSize, XInt aStartIndex = 0 );
/// Default destructor
~ XObjectArray ()
{
Clear ();
}
/// Clear the Array
Void Clear ();
/// Obtain the maximum capacity of the array
XInt getMaxCapacity () const
{
Return 0x7ffff0/sizeof (T );
}
<