📄 classpabstractarray.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>PAbstractArray class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>PAbstractArray Class Reference</h1><code>#include <<a class="el" href="array_8h-source.html">array.h</a>></code><p><p>Inheritance diagram for PAbstractArray:<p><center><img src="classPAbstractArray.png" usemap="#PAbstractArray_map" border="0" alt=""></center><map name="PAbstractArray_map"><area href="classPContainer.html" alt="PContainer" shape="rect" coords="0,56,100,80"><area href="classPObject.html" alt="PObject" shape="rect" coords="0,0,100,24"></map><a href="classPAbstractArray-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td colspan="2"><div class="groupHeader">Construction</div></td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z19_0">PAbstractArray</a> (PINDEX elementSizeInBytes, PINDEX initialSize=0)</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z19_1">PAbstractArray</a> (PINDEX elementSizeInBytes, const void *buffer, PINDEX bufferSizeInElements, BOOL dynamicAllocation)</td></tr><tr><td colspan="2"><div class="groupHeader">Overrides from class PObject</div></td></tr><tr><td nowrap align=right valign=top>virtual void </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z21_0">PrintOn</a> (ostream &strm) const</td></tr><tr><td nowrap align=right valign=top>virtual void </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z21_1">ReadFrom</a> (istream &strm)</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPObject.html#z199_0">Comparison</a> </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z21_2">Compare</a> (const <a class="el" href="classPObject.html">PObject</a> &obj) const</td></tr><tr><td colspan="2"><div class="groupHeader">Overrides from class PContainer</div></td></tr><tr><td nowrap align=right valign=top>virtual BOOL </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z23_0">SetSize</a> (PINDEX newSize)</td></tr><tr><td colspan="2"><div class="groupHeader">New functions for class</div></td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z25_0">Attach</a> (const void *buffer, PINDEX bufferSize)</td></tr><tr><td nowrap align=right valign=top>void * </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z25_1">GetPointer</a> (PINDEX minSize=1)</td></tr><tr><td nowrap align=right valign=top>BOOL </td><td valign=bottom><a class="el" href="classPAbstractArray.html#z25_2">Concatenate</a> (const PAbstractArray &array)</td></tr><tr><td colspan=2><br><h2>Protected Methods</h2></td></tr><tr><td nowrap align=right valign=top>virtual void </td><td valign=bottom><a class="el" href="classPAbstractArray.html#b0">PrintElementOn</a> (ostream &stream, PINDEX index) const</td></tr><tr><td nowrap align=right valign=top>virtual void </td><td valign=bottom><a class="el" href="classPAbstractArray.html#b1">ReadElementFrom</a> (istream &stream, PINDEX index)</td></tr><tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr><tr><td nowrap align=right valign=top>PINDEX </td><td valign=bottom><a class="el" href="classPAbstractArray.html#n0">elementSize</a></td></tr><tr><td> </td><td><font size=-1><em>Size of an element in bytes.</em> <a href="#n0"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>char * </td><td valign=bottom><a class="el" href="classPAbstractArray.html#n1">theArray</a></td></tr><tr><td> </td><td><font size=-1><em>Pointer to the allocated block of memory.</em> <a href="#n1"></a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>BOOL </td><td valign=bottom><a class="el" href="classPAbstractArray.html#n2">allocatedDynamically</a></td></tr><tr><td> </td><td><font size=-1><em>Flag indicating the array was allocated on the heap.</em> <a href="#n2"></a><em></em></font><br><br></td></tr><tr><td colspan=2><br><h2>Friends</h2></td></tr><tr><td nowrap align=right valign=top>class </td><td valign=bottom><a class="el" href="classPAbstractArray.html#l0">PArrayObjects</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>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 {\bf not} include class objects that require construction or destruction. Elements in this array will not execute the contructors or destructors of objects.<p>An abstract array consists of a linear block of memory sufficient to hold PContainer::GetSize()# elements of <a class="el" href="classPAbstractArray.html#n0">elementSize</a># bytes each. The memory block itself will atuomatically be resized when required and freed when no more references to it are present.<p>The PAbstractArray class would very rarely be descended from directly by the user. The <a class="el" href="array_8h.html#a0">PBASEARRAY</a># 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.<p>The PBaseArray# class or <a class="el" href="array_8h.html#a0">PBASEARRAY</a># macro will define the correctly typed operators for pointer access (operator const T *#) and subscript access (operator[]#). <p><hr><h2>Constructor & Destructor Documentation</h2><a name="z19_0" doxytag="PAbstractArray::PAbstractArray"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> PAbstractArray::PAbstractArray </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">PINDEX </td> <td class="mdname" nowrap> <em>elementSizeInBytes</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>PINDEX </td> <td class="mdname" nowrap> <em>initialSize</em> = 0</td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Create a new dynamic array of initalSize# elements of elementSizeInBytes# bytes each. The array memory is initialised to zeros.<p>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 <a class="el" href="array_8h.html#a0">PBASEARRAY</a># macro. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>initialSize</em> </td><td>Size of each element in the array. This must be > 0 or the constructor will assert. Number of elements to allocate initially. </td></tr></table></dl> </td> </tr></table><a name="z19_1" doxytag="PAbstractArray::PAbstractArray"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> PAbstractArray::PAbstractArray </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">PINDEX </td> <td class="mdname" nowrap> <em>elementSizeInBytes</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>const void * </td> <td class="mdname" nowrap> <em>buffer</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>PINDEX </td> <td class="mdname" nowrap> <em>bufferSizeInElements</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>BOOL </td> <td class="mdname" nowrap> <em>dynamicAllocation</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Create a new dynamic array of bufferSizeInElements# elements of elementSizeInBytes# bytes each. The contents of the memory pointed to by buffer is then used to initialise the newly allocated array.<p>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 <a class="el" href="array_8h.html#a0">PBASEARRAY</a># macro.<p>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 <a class="el" href="classPAbstractArray.html#z23_0">SetSize()</a># 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. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>buffer</em> </td><td>Size of each element in the array. This must be > 0 or the constructor will assert. </td></tr><tr><td valign=top><em>bufferSizeInElements</em> </td><td>Pointer to an array of elements. </td></tr><tr><td valign=top><em>dynamicAllocation</em> </td><td>Number of elements pointed to by buffer. Buffer is copied and dynamically allocated. </td></tr></table></dl> </td> </tr></table><hr><h2>Member Function Documentation</h2><a name="z25_0" doxytag="PAbstractArray::Attach"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void PAbstractArray::Attach </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const void * </td> <td class="mdname" nowrap> <em>buffer</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>PINDEX </td> <td class="mdname" nowrap> <em>bufferSize</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Attach a pointer to a static block to the base array type. The pointer is used directly and will not be copied to a dynamically allocated buffer. If the <a class="el" href="classPAbstractArray.html#z23_0">SetSize()</a> 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.<p>Any dynamically allocated buffer will be freed. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>bufferSize</em> </td><td>Pointer to an array of elements. Number of elements pointed to by buffer. </td></tr></table></dl> </td> </tr></table><a name="z21_2" doxytag="PAbstractArray::Compare"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> virtual <a class="el" href="classPObject.html#z199_0">Comparison</a> PAbstractArray::Compare </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="classPObject.html">PObject</a> & </td> <td class="mdname1" valign="top" nowrap> <em>obj</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the relative rank of the two arrays. The following algorithm is employed for the comparison: \begin{description} \item[EqualTo] if the two array memory blocks are identical in length and contents. \item[LessThan] if the array length is less than the obj# parameters array length. \item[GreaterThan] if the array length is greater than the obj# parameters array length. \end{description}<p>If the array sizes are identical then the memcmp()# function is used to rank the two arrays.<p><dl compact><dt><b>Returns: </b></dt><dd> comparison of the two objects, <a class="el" href="classPObject.html#z199_0s1">EqualTo</a># for same, <a class="el" href="classPObject.html#z199_0s0">LessThan</a># for obj# logically less than the object and <a class="el" href="classPObject.html#z199_0s2">GreaterThan</a># for obj# logically greater than the object. </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>obj</em> </td><td>Other PAbstractArray to compare against. </td></tr></table></dl><p>Reimplemented from <a class="el" href="classPObject.html#z199_1">PObject</a>. </td> </tr></table><a name="z25_2" doxytag="PAbstractArray::Concatenate"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> BOOL PAbstractArray::Concatenate </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const PAbstractArray & </td> <td class="mdname1" valign="top" nowrap> <em>array</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Concatenate one array to the end of this array. This function will allocate a new array large enough for the existing contents and the contents of the parameter. The paramters contents is then copied to the end of the existing array.<p>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.<p><dl compact><dt><b>Returns: </b></dt><dd> TRUE if the memory allocation succeeded. </dl><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>array</em> </td><td>Array to concatenate. </td></tr></table></dl> </td> </tr></table><a name="z25_1" doxytag="PAbstractArray::GetPointer"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void* PAbstractArray::GetPointer </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">PINDEX </td> <td class="mdname1" valign="top" nowrap> <em>minSize</em> = 1 </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -