Common Library Dynamic Object array template class

Source: Internet
Author: User

/// 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 );
}

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.