📄 classpcollection.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>PCollection 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>PCollection Class Reference</h1><code>#include <<a class="el" href="contain_8h-source.html">contain.h</a>></code><p><p>Inheritance diagram for PCollection:<p><center><img src="classPCollection.png" usemap="#PCollection_map" border="0" alt=""></center><map name="PCollection_map"><area href="classPContainer.html" alt="PContainer" shape="rect" coords="135,56,260,80"><area href="classPObject.html" alt="PObject" shape="rect" coords="135,0,260,24"><area href="classPAbstractList.html" alt="PAbstractList" shape="rect" coords="0,168,125,192"><area href="classPAbstractSortedList.html" alt="PAbstractSortedList" shape="rect" coords="135,168,260,192"><area href="classPHashTable.html" alt="PHashTable" shape="rect" coords="270,168,395,192"><area href="classPAbstractDictionary.html" alt="PAbstractDictionary" shape="rect" coords="202,224,327,248"><area href="classPAbstractSet.html" alt="PAbstractSet" shape="rect" coords="337,224,462,248"></map><a href="classPCollection-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="classPCollection.html#z71_0">PCollection</a> (PINDEX initialSize=0)</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="classPCollection.html#z73_0">PrintOn</a> (ostream &strm) const</td></tr><tr><td colspan="2"><div class="groupHeader">Common functions for collections</div></td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPCollection.html#z75_0">Append</a> (<a class="el" href="classPObject.html">PObject</a> *obj)=0</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPCollection.html#z75_1">Insert</a> (const <a class="el" href="classPObject.html">PObject</a> &before, <a class="el" href="classPObject.html">PObject</a> *obj)=0</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPCollection.html#z75_2">InsertAt</a> (PINDEX index, <a class="el" href="classPObject.html">PObject</a> *obj)=0</td></tr><tr><td nowrap align=right valign=top>virtual BOOL </td><td valign=bottom><a class="el" href="classPCollection.html#z75_3">Remove</a> (const <a class="el" href="classPObject.html">PObject</a> *obj)=0</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPObject.html">PObject</a> * </td><td valign=bottom><a class="el" href="classPCollection.html#z75_4">RemoveAt</a> (PINDEX index)=0</td></tr><tr><td nowrap align=right valign=top>virtual void </td><td valign=bottom><a class="el" href="classPCollection.html#z75_5">RemoveAll</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL </td><td valign=bottom><a class="el" href="classPCollection.html#z75_6">SetAt</a> (PINDEX index, <a class="el" href="classPObject.html">PObject</a> *val)=0</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPObject.html">PObject</a> * </td><td valign=bottom><a class="el" href="classPCollection.html#z75_7">GetAt</a> (PINDEX index) const=0</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPCollection.html#z75_8">GetObjectsIndex</a> (const <a class="el" href="classPObject.html">PObject</a> *obj) const=0</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPCollection.html#z75_9">GetValuesIndex</a> (const <a class="el" href="classPObject.html">PObject</a> &obj) const=0</td></tr><tr><td nowrap align=right valign=top>PINLINE void </td><td valign=bottom><a class="el" href="classPCollection.html#z75_10">AllowDeleteObjects</a> (BOOL yes=TRUE)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPCollection.html#z75_11">DisallowDeleteObjects</a> ()</td></tr><tr><td colspan=2><br><h2>Protected Methods</h2></td></tr><tr><td nowrap align=right valign=top>PINLINE </td><td valign=bottom><a class="el" href="classPCollection.html#b0">PCollection</a> (int dummy, const PCollection *coll)</td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>A collection is a container that collects together descendents of the <a class="el" href="classPObject.html#b0">PObject</a># class. The objects contained in the collection are always pointers to objects, not the objects themselves. The life of an object in the collection should be carefully considered. Typically, it is allocated by the user of the collection when it is added. The collection then automatically deletes it when it is removed or the collection is destroyed, ie when the container class has no more references to the collection. Other models may be accommodated but it is up to the programmer to determine the scope and life of the objects.<p>The exact form of the collection depends on the descendent of PCollection and determines the access modes for the objects in it. Thus a collection can be an array which allows fast random access at the expense of slow insertion and deletion. Or the collection may be a list which has fast insertion and deletion but very slow random access.<p>The basic paradigm of all collections is the "virtual array". Regardless of the internal implementation of the collection; array, list, sorted list etc, the user may access elements via an ordinal index. The implementation then optimises the access as best it can. For instance, in a list ordinal zero will go directly to the head of the list. Stepping along sequential indexes then will return the next element of the list, remembering the new position at each step, thus allowing sequential access with little overhead as is expected for lists. If a random location is specified, then the list implementation must sequentially search for that ordinal from either the last location or an end of the list, incurring an overhead.<p>All collection classes implement a base set of functions, though they may be meaningless or degenerative in some collection types eg <a class="el" href="classPCollection.html#z75_1">Insert()</a># for PSortedList# will degenerate to be the same as <a class="el" href="classPCollection.html#z75_0">Append()</a>#. <p><hr><h2>Constructor & Destructor Documentation</h2><a name="z71_0" doxytag="PCollection::PCollection"></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"> PINLINE PCollection::PCollection </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">PINDEX </td> <td class="mdname1" valign="top" nowrap> <em>initialSize</em> = 0 </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>Create a new collection <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>initialSize</em> </td><td>Initial number of things in the collection. </td></tr></table></dl> </td> </tr></table><a name="b0" doxytag="PCollection::PCollection"></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"> PINLINE PCollection::PCollection </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>dummy</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>const PCollection * </td> <td class="mdname" nowrap> <em>coll</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Constructor used in support of the <a class="el" href="classPObject.html#z203_0">Clone()</a> function. This creates a new unique reference of a copy of the contents. It does {\bf not} create another reference.<p>The dummy parameter is there to prevent the contructor from being invoked automatically by the compiler when a pointer is used by accident when a normal instance or reference was expected. The container would be silently cloned and the copy used instead of the container expected leading to unpredictable results. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>c</em> </td><td>Dummy to prevent accidental use of the constructor. Collection class to clone. </td></tr></table></dl> </td> </tr></table><hr><h2>Member Function Documentation</h2><a name="z75_10" doxytag="PCollection::AllowDeleteObjects"></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"> PINLINE void PCollection::AllowDeleteObjects </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">BOOL </td> <td class="mdname1" valign="top" nowrap> <em>yes</em> = TRUE </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>Allow or disallow the deletion of the objects contained in the collection. If TRUE then whenever an object is removed, overwritten or the colelction is deleted due to all references being destroyed, the object is deleted.<p>For example: \begin{verbatim} coll.SetAt(2, new <a class="el" href="classPString.html">PString</a>("one")); coll.SetAt(2, new <a class="el" href="classPString.html">PString</a>("Two")); \end{verbatim} would automatically delete the string containing "one" on the second call to <a class="el" href="classPCollection.html#z75_6">SetAt()</a>. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>yes</em> </td><td>New value for flag for deleting objects </td></tr></table></dl> </td> </tr></table><a name="z75_0" doxytag="PCollection::Append"></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 PINDEX PCollection::Append </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><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><code> [pure virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Append a new object to the collection.<p>The exact semantics depends on the specific type of the collection. So the function may not place the object at the "end" of the collection at all. For example, in a PSortedList# the object is placed in the correct ordinal position in the list.<p><dl compact><dt><b>Returns: </b></dt><dd>index of the newly added 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>New object to place into the collection. </td></tr></table></dl><p>Implemented in <a class="el" href="classPAbstractSet.html#z97_0">PAbstractSet</a>, <a class="el" href="classPAbstractList.html#z175_0">PAbstractList</a>, and <a class="el" href="classPAbstractSortedList.html#z183_0">PAbstractSortedList</a>. </td> </tr></table><a name="z75_11" doxytag="PCollection::DisallowDeleteObjects"></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"> PINLINE void PCollection::DisallowDeleteObjects </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -